| Issue |
235619
|
| Summary |
[BOLT][AArch64] Undefined temporary symbol .Ltmp0 for reference into function padding
|
| Labels |
BOLT
|
| Assignees |
|
| Reporter |
yashssh
|
Reproducer
```
// Minimal reproducer: stock BOLT (rev cbc5a226) "Undefined temporary symbol .Ltmp0 / Emission failed" on AArch64.
// foo has 4 bytes of zero padding after it, then an unnamed function (no symbol, no .size).
// foo references that unnamed code through two section-symbol+addend relocations: CALL26 and ADR_PREL_PG_HI21.
.text
.globl foo
.type foo,%function
foo:
.reloc ., R_AARCH64_CALL26, .text+16
.inst 0x94000000 // bl <unnamed>
.reloc ., R_AARCH64_ADR_PREL_PG_HI21, .text+16
.inst 0x90000001 // adrp x1, <unnamed>
ret
.size foo, .-foo
.word 0 // zero padding (udf #0), as in libnvrtc
ret // foo+16: unnamed code, no symbol
.balign 16
.globl next
.type next,%function
next:
ret
.size next, .-next
.globl _start
_start:
bl foo
bl next
mov w0, #0
ret
```
```
gcc -c repro.s -o /tmp/r.o
ld /tmp/r.o -o /tmp/r --emit-relocs -e _start
llvm-bolt /tmp/r -o /tmp/r.stock --relocs
```
```
BOLT-WARNING: function foo has an object detected in a padding region at address 0x4000c0
<unknown>:0: error: Undefined temporary symbol .Ltmp0
BOLT-ERROR: Emission failed.
```
My understanding of the root cause:
The relocations in foo point to `foo+16` (which is a unnamed function outside foo). However BOLT finds that address to be inside foo's padding and treats it as reference inside the function `foo` itself. Hence creating a label and extra entry point at an offset 16 from `foo`.
However `foo`'s real size is 12 so while rewriting `foo`'s code BOLT stops at offset 12 and nothing is placed at offset 16 and the label is never defined. Another instruction still refers to that label. The assembler streamer finds a symbol that was used but never defined and reports `Undefined temporary symbol .Ltmp0`.
The reproducer was extracted with the help of Claude from a much larger binary I was optimising with BOLT.
I have a fix ready which fixes the bug by making sure BOLT does not treat the addresses inside the function's padding as inside the function.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs