[PATCH v2] aarch64: Emit jump slot for conditional branches to weak_undef
Siddhesh Poyarekar
siddhesh@gotplt.org
Mon May 18 04:47:41 GMT 2020
On 18/05/20 03:24, Fangrui Song wrote:
> Yes, LLD resolves such relocations referencing an undefined weak
> symbol to the next instruction.
> https://github.com/llvm/llvm-project/blob/master/lld/ELF/InputSection.cpp#L543
Right, we kinda do something similar in bfd ld too; for JUMP26 and
CALL26 we insert a NOP and for CONDBR19 and TSTBR14 we emit a
conditional jump to itself, i.e. go to the next instruction if false.
The working assumption seems to be that the condition will always be
false and we will move to the next instruction but that's an assumption
on my part.
The question here is whether we do for TSTBR14 and CONDBR19 what we do
for JUMP26 and CALL26 (i.e. just insert a nop) or try to retain the old
behaviour, i.e branch to itself when true. I've done the latter for now
in the interest of minimal change, but it seems more correct to do the
former.
> Is there a better way organizing ld/testsuite/ld-aarch64/emit-relocs-*
> tests 😀 ? We've now reached 560...
It's probably a question that should have been asked before reaching a
100 emit-relocs tests ;) I'm happy to rename it if needed, ut given
that 559 tests before this were OK, I reckon there's a ~0.2% chance of
my naming choice being wrong :D
> A test like (https://github.com/llvm/llvm-project/blob/master/lld/test/ELF/aarch64-undefined-weak.s)
>
> .weak target
>
> .globl _start
> _start:
> b target
> bl target
> b.eq target
> cbz x1, target
>
> in -no-pie and -shared modes can provide enough coverage.
The undefined-weak.s test already covers this. My change (sorry, the
subject line is incorrect) is about undefined non-weak symbols.
Siddhesh
More information about the Binutils
mailing list