2011-01-24 11:56:40 +03:00
|
|
|
#
|
2012-05-21 15:12:37 +04:00
|
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2011-01-24 11:56:40 +03:00
|
|
|
|
|
|
|
INTERNAL_TOOLS = 1
|
|
|
|
|
2011-08-29 09:34:12 +04:00
|
|
|
NO_PROFILE_GUIDED_OPTIMIZE = 1
|
2011-01-24 11:56:40 +03:00
|
|
|
|
2011-04-15 13:03:17 +04:00
|
|
|
VPATH += $(topsrcdir)/build
|
|
|
|
|
2011-01-28 11:22:58 +03:00
|
|
|
OS_CXXFLAGS := $(filter-out -fno-exceptions,$(OS_CXXFLAGS)) -fexceptions
|
2011-01-24 11:56:40 +03:00
|
|
|
|
2011-08-29 21:21:22 +04:00
|
|
|
WRAP_LDFLAGS=
|
2011-08-09 11:05:49 +04:00
|
|
|
|
2011-08-29 09:34:02 +04:00
|
|
|
include $(topsrcdir)/config/rules.mk
|
|
|
|
|
2013-10-17 08:36:13 +04:00
|
|
|
DEFINES += -DELFHACK_BUILD
|
|
|
|
|
2013-11-01 05:30:45 +04:00
|
|
|
test-array$(DLL_SUFFIX) test-ctors$(DLL_SUFFIX): %$(DLL_SUFFIX): %.$(OBJ_SUFFIX) elfhack
|
2012-08-09 18:34:26 +04:00
|
|
|
$(MKSHLIB) $(LDFLAGS) $< -nostartfiles
|
2011-01-28 11:22:58 +03:00
|
|
|
@echo ===
|
|
|
|
@echo === If you get failures below, please file a bug describing the error
|
|
|
|
@echo === and your environment \(compiler and linker versions\), and use
|
|
|
|
@echo === --disable-elf-hack until this is fixed.
|
|
|
|
@echo ===
|
2012-08-09 18:34:26 +04:00
|
|
|
# Fail if the library doesn't have $(DT_TYPE) .dynamic info
|
|
|
|
$(TOOLCHAIN_PREFIX)readelf -d $@ | grep '($(DT_TYPE))'
|
2011-01-28 11:22:58 +03:00
|
|
|
@rm -f $@.bak
|
2012-02-21 11:08:41 +04:00
|
|
|
$(CURDIR)/elfhack -b -f $@
|
2011-01-24 11:56:40 +03:00
|
|
|
# Fail if the backup file doesn't exist
|
|
|
|
[ -f "$@.bak" ]
|
|
|
|
# Fail if the new library doesn't contain less relocations
|
2012-08-09 18:34:26 +04:00
|
|
|
[ $$($(TOOLCHAIN_PREFIX)objdump -R $@.bak | wc -l) -gt $$(objdump -R $@ | wc -l) ]
|
2011-01-24 11:56:40 +03:00
|
|
|
|
2012-08-09 18:34:26 +04:00
|
|
|
test-array$(DLL_SUFFIX): DT_TYPE=INIT_ARRAY
|
|
|
|
test-ctors$(DLL_SUFFIX): DT_TYPE=INIT
|
2011-07-28 11:05:15 +04:00
|
|
|
|
2012-08-09 18:34:26 +04:00
|
|
|
.PRECIOUS: test-array$(DLL_SUFFIX) test-ctors$(DLL_SUFFIX)
|
2011-08-09 11:05:49 +04:00
|
|
|
|
2012-08-09 18:34:26 +04:00
|
|
|
GARBAGE += test-array$(DLL_SUFFIX) test-ctors$(DLL_SUFFIX) test-array$(DLL_SUFFIX).bak test-ctors$(DLL_SUFFIX).bak
|
|
|
|
|
|
|
|
libs:: test-array$(DLL_SUFFIX) test-ctors$(DLL_SUFFIX)
|
2011-08-09 11:05:49 +04:00
|
|
|
|
|
|
|
ifndef CROSS_COMPILE
|
2012-08-09 18:34:26 +04:00
|
|
|
dummy: dummy.$(OBJ_SUFFIX)
|
2011-05-17 11:34:20 +04:00
|
|
|
$(CC) -o $@ $^ $(LDFLAGS)
|
2011-01-24 11:56:40 +03:00
|
|
|
|
|
|
|
libs:: dummy
|
|
|
|
# Will either crash or return exit code 1 if elfhack is broken
|
2012-08-09 18:34:26 +04:00
|
|
|
LD_PRELOAD=$(CURDIR)/test-array$(DLL_SUFFIX) $(CURDIR)/dummy
|
|
|
|
LD_PRELOAD=$(CURDIR)/test-ctors$(DLL_SUFFIX) $(CURDIR)/dummy
|
2011-01-24 11:56:40 +03:00
|
|
|
|
2011-08-09 11:05:49 +04:00
|
|
|
GARBAGE += dummy
|
2011-01-24 11:56:40 +03:00
|
|
|
endif
|
|
|
|
|
2011-02-23 12:06:26 +03:00
|
|
|
test.$(OBJ_SUFFIX): CFLAGS := -O0
|