|
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 |
|
6 INTERNAL_TOOLS = 1 |
|
7 |
|
8 OS_CXXFLAGS := $(filter-out -fno-exceptions,$(OS_CXXFLAGS)) -fexceptions |
|
9 |
|
10 WRAP_LDFLAGS= |
|
11 |
|
12 include $(topsrcdir)/config/rules.mk |
|
13 |
|
14 test-array$(DLL_SUFFIX) test-ctors$(DLL_SUFFIX): %$(DLL_SUFFIX): %.$(OBJ_SUFFIX) elfhack |
|
15 $(MKSHLIB) $(LDFLAGS) $< -nostartfiles |
|
16 @echo === |
|
17 @echo === If you get failures below, please file a bug describing the error |
|
18 @echo === and your environment \(compiler and linker versions\), and use |
|
19 @echo === --disable-elf-hack until this is fixed. |
|
20 @echo === |
|
21 # Fail if the library doesn't have $(DT_TYPE) .dynamic info |
|
22 $(TOOLCHAIN_PREFIX)readelf -d $@ | grep '($(DT_TYPE))' |
|
23 @rm -f $@.bak |
|
24 $(CURDIR)/elfhack -b -f $@ |
|
25 # Fail if the backup file doesn't exist |
|
26 [ -f '$@.bak' ] |
|
27 # Fail if the new library doesn't contain less relocations |
|
28 [ $$($(TOOLCHAIN_PREFIX)objdump -R $@.bak | wc -l) -gt $$(objdump -R $@ | wc -l) ] |
|
29 |
|
30 test-array$(DLL_SUFFIX): DT_TYPE=INIT_ARRAY |
|
31 test-ctors$(DLL_SUFFIX): DT_TYPE=INIT |
|
32 |
|
33 .PRECIOUS: test-array$(DLL_SUFFIX) test-ctors$(DLL_SUFFIX) |
|
34 |
|
35 GARBAGE += test-array$(DLL_SUFFIX) test-ctors$(DLL_SUFFIX) test-array$(DLL_SUFFIX).bak test-ctors$(DLL_SUFFIX).bak |
|
36 |
|
37 ifndef CROSS_COMPILE |
|
38 ifdef COMPILE_ENVIRONMENT |
|
39 libs:: test-array$(DLL_SUFFIX) test-ctors$(DLL_SUFFIX) |
|
40 |
|
41 dummy: dummy.$(OBJ_SUFFIX) |
|
42 $(CC) -o $@ $^ $(LDFLAGS) |
|
43 |
|
44 libs:: dummy |
|
45 # Will either crash or return exit code 1 if elfhack is broken |
|
46 LD_PRELOAD=$(CURDIR)/test-array$(DLL_SUFFIX) $(CURDIR)/dummy |
|
47 LD_PRELOAD=$(CURDIR)/test-ctors$(DLL_SUFFIX) $(CURDIR)/dummy |
|
48 |
|
49 GARBAGE += dummy |
|
50 endif |
|
51 endif |