llvm.org GIT mirror llvm / d741fc0
[PowerPC] undef Relocation names in PowerPC*.def glibc's PowerPC /usr/include/asm/sigcontext.h, has this: #ifdef __powerpc64__ #include <asm/elf.h> #endif and that contains defines of all of the relocation symbols, like this: #define R_PPC_NONE 0 and if that file is included prior to including include/llvm/Support/ELFRelocs/PowerPC*.def, which we cannot in general prevent, the result will fail. As it turns out, this happens when compiling lld/unittests/DriverTests/GnuLdDriverTest.cpp under PPC64/Linux, because: lld/include/lld/ReaderWriter/ELFLinkingContext.h includes lld/unittests/DriverTests/DriverTest.h which includes utils/unittest/googletest/include/gtest/gtest.h which includes utils/unittest/googletest/include/gtest/internal/gtest-internal.h which includes /usr/include/sys/wait.h which includes /usr/include/signal.h which includes /usr/include/bits/sigcontext.h which includes /usr/include/asm/sigcontext.h which includes /usr/include/asm/elf.h the test could be fixed to include ReaderWriter/ELFLinkingContext.h before including unittests/DriverTests/DriverTest.h, but dealing with this in the *.def files is a more-general solution that localizes the fix to the headers instead of requiring changes to an unbounded number of other source files (both in-tree and external). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@248957 91177308-0d34-0410-b5e6-96231b3b80d8 Hal Finkel 4 years ago
2 changed file(s) with 151 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
11 #ifndef ELF_RELOC
22 #error "ELF_RELOC must be defined"
33 #endif
4
5 // glibc's PowerPC asm/sigcontext.h, when compiling for PPC64, has the
6 // unfortunate behavior of including asm/elf.h, which defines R_PPC_NONE, etc.
7 // to their corresponding integer values. As a result, we need to undef them
8 // here before continuing.
9
10 #undef R_PPC_NONE
11 #undef R_PPC_ADDR32
12 #undef R_PPC_ADDR24
13 #undef R_PPC_ADDR16
14 #undef R_PPC_ADDR16_LO
15 #undef R_PPC_ADDR16_HI
16 #undef R_PPC_ADDR16_HA
17 #undef R_PPC_ADDR14
18 #undef R_PPC_ADDR14_BRTAKEN
19 #undef R_PPC_ADDR14_BRNTAKEN
20 #undef R_PPC_REL24
21 #undef R_PPC_REL14
22 #undef R_PPC_REL14_BRTAKEN
23 #undef R_PPC_REL14_BRNTAKEN
24 #undef R_PPC_GOT16
25 #undef R_PPC_GOT16_LO
26 #undef R_PPC_GOT16_HI
27 #undef R_PPC_GOT16_HA
28 #undef R_PPC_PLTREL24
29 #undef R_PPC_JMP_SLOT
30 #undef R_PPC_LOCAL24PC
31 #undef R_PPC_REL32
32 #undef R_PPC_TLS
33 #undef R_PPC_DTPMOD32
34 #undef R_PPC_TPREL16
35 #undef R_PPC_TPREL16_LO
36 #undef R_PPC_TPREL16_HI
37 #undef R_PPC_TPREL16_HA
38 #undef R_PPC_TPREL32
39 #undef R_PPC_DTPREL16
40 #undef R_PPC_DTPREL16_LO
41 #undef R_PPC_DTPREL16_HI
42 #undef R_PPC_DTPREL16_HA
43 #undef R_PPC_DTPREL32
44 #undef R_PPC_GOT_TLSGD16
45 #undef R_PPC_GOT_TLSGD16_LO
46 #undef R_PPC_GOT_TLSGD16_HI
47 #undef R_PPC_GOT_TLSGD16_HA
48 #undef R_PPC_GOT_TLSLD16
49 #undef R_PPC_GOT_TLSLD16_LO
50 #undef R_PPC_GOT_TLSLD16_HI
51 #undef R_PPC_GOT_TLSLD16_HA
52 #undef R_PPC_GOT_TPREL16
53 #undef R_PPC_GOT_TPREL16_LO
54 #undef R_PPC_GOT_TPREL16_HI
55 #undef R_PPC_GOT_TPREL16_HA
56 #undef R_PPC_GOT_DTPREL16
57 #undef R_PPC_GOT_DTPREL16_LO
58 #undef R_PPC_GOT_DTPREL16_HI
59 #undef R_PPC_GOT_DTPREL16_HA
60 #undef R_PPC_TLSGD
61 #undef R_PPC_TLSLD
62 #undef R_PPC_REL16
63 #undef R_PPC_REL16_LO
64 #undef R_PPC_REL16_HI
65 #undef R_PPC_REL16_HA
466
567 ELF_RELOC(R_PPC_NONE, 0) /* No relocation. */
668 ELF_RELOC(R_PPC_ADDR32, 1)
11 #ifndef ELF_RELOC
22 #error "ELF_RELOC must be defined"
33 #endif
4
5 // glibc's PowerPC asm/sigcontext.h, when compiling for PPC64, has the
6 // unfortunate behavior of including asm/elf.h, which defines R_PPC_NONE, etc.
7 // to their corresponding integer values. As a result, we need to undef them
8 // here before continuing.
9
10 #undef R_PPC64_NONE
11 #undef R_PPC64_ADDR32
12 #undef R_PPC64_ADDR24
13 #undef R_PPC64_ADDR16
14 #undef R_PPC64_ADDR16_LO
15 #undef R_PPC64_ADDR16_HI
16 #undef R_PPC64_ADDR16_HA
17 #undef R_PPC64_ADDR14
18 #undef R_PPC64_ADDR14_BRTAKEN
19 #undef R_PPC64_ADDR14_BRNTAKEN
20 #undef R_PPC64_REL24
21 #undef R_PPC64_REL14
22 #undef R_PPC64_REL14_BRTAKEN
23 #undef R_PPC64_REL14_BRNTAKEN
24 #undef R_PPC64_GOT16
25 #undef R_PPC64_GOT16_LO
26 #undef R_PPC64_GOT16_HI
27 #undef R_PPC64_GOT16_HA
28 #undef R_PPC64_JMP_SLOT
29 #undef R_PPC64_REL32
30 #undef R_PPC64_ADDR64
31 #undef R_PPC64_ADDR16_HIGHER
32 #undef R_PPC64_ADDR16_HIGHERA
33 #undef R_PPC64_ADDR16_HIGHEST
34 #undef R_PPC64_ADDR16_HIGHESTA
35 #undef R_PPC64_REL64
36 #undef R_PPC64_TOC16
37 #undef R_PPC64_TOC16_LO
38 #undef R_PPC64_TOC16_HI
39 #undef R_PPC64_TOC16_HA
40 #undef R_PPC64_TOC
41 #undef R_PPC64_ADDR16_DS
42 #undef R_PPC64_ADDR16_LO_DS
43 #undef R_PPC64_GOT16_DS
44 #undef R_PPC64_GOT16_LO_DS
45 #undef R_PPC64_TOC16_DS
46 #undef R_PPC64_TOC16_LO_DS
47 #undef R_PPC64_TLS
48 #undef R_PPC64_DTPMOD64
49 #undef R_PPC64_TPREL16
50 #undef R_PPC64_TPREL16_LO
51 #undef R_PPC64_TPREL16_HI
52 #undef R_PPC64_TPREL16_HA
53 #undef R_PPC64_TPREL64
54 #undef R_PPC64_DTPREL16
55 #undef R_PPC64_DTPREL16_LO
56 #undef R_PPC64_DTPREL16_HI
57 #undef R_PPC64_DTPREL16_HA
58 #undef R_PPC64_DTPREL64
59 #undef R_PPC64_GOT_TLSGD16
60 #undef R_PPC64_GOT_TLSGD16_LO
61 #undef R_PPC64_GOT_TLSGD16_HI
62 #undef R_PPC64_GOT_TLSGD16_HA
63 #undef R_PPC64_GOT_TLSLD16
64 #undef R_PPC64_GOT_TLSLD16_LO
65 #undef R_PPC64_GOT_TLSLD16_HI
66 #undef R_PPC64_GOT_TLSLD16_HA
67 #undef R_PPC64_GOT_TPREL16_DS
68 #undef R_PPC64_GOT_TPREL16_LO_DS
69 #undef R_PPC64_GOT_TPREL16_HI
70 #undef R_PPC64_GOT_TPREL16_HA
71 #undef R_PPC64_GOT_DTPREL16_DS
72 #undef R_PPC64_GOT_DTPREL16_LO_DS
73 #undef R_PPC64_GOT_DTPREL16_HI
74 #undef R_PPC64_GOT_DTPREL16_HA
75 #undef R_PPC64_TPREL16_DS
76 #undef R_PPC64_TPREL16_LO_DS
77 #undef R_PPC64_TPREL16_HIGHER
78 #undef R_PPC64_TPREL16_HIGHERA
79 #undef R_PPC64_TPREL16_HIGHEST
80 #undef R_PPC64_TPREL16_HIGHESTA
81 #undef R_PPC64_DTPREL16_DS
82 #undef R_PPC64_DTPREL16_LO_DS
83 #undef R_PPC64_DTPREL16_HIGHER
84 #undef R_PPC64_DTPREL16_HIGHERA
85 #undef R_PPC64_DTPREL16_HIGHEST
86 #undef R_PPC64_DTPREL16_HIGHESTA
87 #undef R_PPC64_TLSGD
88 #undef R_PPC64_TLSLD
89 #undef R_PPC64_REL16
90 #undef R_PPC64_REL16_LO
91 #undef R_PPC64_REL16_HI
92 #undef R_PPC64_REL16_HA
493
594 ELF_RELOC(R_PPC64_NONE, 0)
695 ELF_RELOC(R_PPC64_ADDR32, 1)