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
|
|
|
|
2011-08-29 09:34:02 +04:00
|
|
|
include $(topsrcdir)/config/rules.mk
|
|
|
|
|
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
|
2017-07-31 17:35:03 +03:00
|
|
|
@echo === and your environment \(compiler and linker versions\), and
|
|
|
|
@echo === provide the pre-elfhacked library as an attachment.
|
|
|
|
@echo === Use --disable-elf-hack until this is fixed.
|
2011-01-28 11:22:58 +03:00
|
|
|
@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
|
2013-12-03 01:34:21 +04:00
|
|
|
[ -f '$@.bak' ]
|
2011-01-24 11:56:40 +03:00
|
|
|
# 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
|
|
|
|
2014-07-25 02:08:34 +04:00
|
|
|
test-array$(DLL_SUFFIX) test-ctors$(DLL_SUFFIX): DSO_SONAME=$@
|
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
|
|
|
|
|
2013-11-07 05:37:45 +04:00
|
|
|
ifndef CROSS_COMPILE
|
|
|
|
ifdef COMPILE_ENVIRONMENT
|
2012-08-09 18:34:26 +04:00
|
|
|
libs:: test-array$(DLL_SUFFIX) test-ctors$(DLL_SUFFIX)
|
2011-08-09 11:05:49 +04:00
|
|
|
|
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
|
2013-11-07 05:37:45 +04:00
|
|
|
endif
|