1# 2# This Source Code Form is subject to the terms of the Mozilla Public 3# License, v. 2.0. If a copy of the MPL was not distributed with this 4# file, You can obtain one at http://mozilla.org/MPL/2.0/. 5 6include $(topsrcdir)/config/rules.mk 7 8test-array$(DLL_SUFFIX) test-ctors$(DLL_SUFFIX): %$(DLL_SUFFIX): %.$(OBJ_SUFFIX) elfhack 9 $(MKSHLIB) $(LDFLAGS) $< -nostartfiles 10 @echo === 11 @echo === If you get failures below, please file a bug describing the error 12 @echo === and your environment \(compiler and linker versions\), and 13 @echo === provide the pre-elfhacked library as an attachment. 14 @echo === Use --disable-elf-hack until this is fixed. 15 @echo === 16 # Fail if the library doesn't have $(DT_TYPE) .dynamic info 17 $(TOOLCHAIN_PREFIX)readelf -d $@ | grep '($(DT_TYPE))' 18 @rm -f $@.bak 19 $(CURDIR)/elfhack -b -f $@ 20 # Fail if the backup file doesn't exist 21 [ -f '$@.bak' ] 22 # Fail if the new library doesn't contain less relocations 23 [ $$($(TOOLCHAIN_PREFIX)objdump -R $@.bak | wc -l) -gt $$(objdump -R $@ | wc -l) ] 24 25test-array$(DLL_SUFFIX) test-ctors$(DLL_SUFFIX): DSO_SONAME=$@ 26test-array$(DLL_SUFFIX): DT_TYPE=INIT_ARRAY 27test-ctors$(DLL_SUFFIX): DT_TYPE=INIT 28 29.PRECIOUS: test-array$(DLL_SUFFIX) test-ctors$(DLL_SUFFIX) 30 31ifndef CROSS_COMPILE 32ifdef COMPILE_ENVIRONMENT 33libs:: test-array$(DLL_SUFFIX) test-ctors$(DLL_SUFFIX) 34 35dummy: dummy.$(OBJ_SUFFIX) 36 $(CC) -o $@ $^ $(LDFLAGS) 37 38libs:: dummy 39 # Will either crash or return exit code 1 if elfhack is broken 40 LD_PRELOAD=$(CURDIR)/test-array$(DLL_SUFFIX) $(CURDIR)/dummy 41 LD_PRELOAD=$(CURDIR)/test-ctors$(DLL_SUFFIX) $(CURDIR)/dummy 42 43endif 44endif 45