Issue |
83265
|
Summary |
s390/clang: relocation error : when there is a weak undefined symbol + -fno-PIE and -munaligned-symbols
|
Labels |
|
Assignees |
|
Reporter |
sumanthkorikkar
|
Problem:
=======
When the symbol is weak and undefined + when the section layout is > 4GB, then it can end up with relocation error.
sample.c:6:(.text+0xc): relocation truncated to fit: R_390_PC32DBL against undefined symbol `kallsyms_markers'
Reproducer:
==========
1. cat sample.c
extern const char kallsyms_names[] __attribute__((weak));
extern const unsigned int kallsyms_markers[] __attribute__((weak));
const char *data;
int main(void)
{
data = ""
}
2. clang -g -c sample.c -munaligned-symbols -fno-PIE
3. cat layout.ld
SECTIONS { . = 0x200000000; }
4. ld --script=layout.ld -o sample sample.o
sample.o: in function `main':
sample.c:6:(.text+0xc): relocation truncated to fit: R_390_PC32DBL against undefined symbol `kallsyms_markers'
Disassembly:
===========
`Disassembly of section .text:`
`0000000000000000 <main>:`
`extern const char kallsyms_names[] __attribute__((weak));`
`extern const unsigned int kallsyms_markers[] __attribute__((weak));`
`const char *data;`
`int main(void)`
`{`
`0: eb bf f0 58 00 24 stmg %r11,%r15,88(%r15)`
`6: b9 04 00 bf lgr %r11,%r15`
`data = ""
`a: c4 0e 00 00 00 00 llgfrl %r0,a <main+0xa>`
`c: R_390_PC32DBL kallsyms_markers+0x2` <<<<
`10: c4 18 00 00 00 00 lgrl %r1,10 <main+0x10>`
`12: R_390_GOTENT kallsyms_names+0x2`
`16: b9 08 00 01 agr %r0,%r1`
`1a: c4 0b 00 00 00 00 stgrl %r0,1a <main+0x1a>`
`1c: R_390_PC32DBL data+0x2`
` 20: a7 29 00 00 lghi %r2,0`
`}`
`24: eb bf b0 58 00 04 lmg %r11,%r15,88(%r11)`
` 2a: 07 fe br %r14`
When .text layout is > 4GB and when kallsyms_markers is weak undefined, then it could
end up with relocation truncated to fit: R_390_PC32DBL against undefined symbol `kallsyms_markers'
Misc:
=====
gcc doesnt have this problem with -mualigned-symbols and works fine with the same example
Thank you,
Sumanth
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs