[all-commits] [llvm/llvm-project] 2bfee3: [MC][ELF] Emit a relocation if target is defined i...
Fangrui Song via All-commits
all-commits at lists.llvm.org
Sun Jan 12 13:46:29 PST 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: 2bfee35cb860859b436de0b780fbd00d68e198a4
https://github.com/llvm/llvm-project/commit/2bfee35cb860859b436de0b780fbd00d68e198a4
Author: Fangrui Song <maskray at google.com>
Date: 2020-01-12 (Sun, 12 Jan 2020)
Changed paths:
M lld/test/ELF/global-offset-table-position-aarch64.s
M llvm/lib/MC/ELFObjectWriter.cpp
M llvm/test/MC/ARM/thumb1-branch-reloc.s
M llvm/test/MC/ARM/thumb2-beq-fixup.s
R llvm/test/MC/ELF/relax.s
A llvm/test/MC/ELF/target-in-same-section.s
M llvm/test/MC/X86/align-branch-64-2a.s
M llvm/test/MC/X86/align-branch-64-2b.s
M llvm/test/MC/X86/align-branch-64-2c.s
Log Message:
-----------
[MC][ELF] Emit a relocation if target is defined in the same section and is non-local
For a target symbol defined in the same section, currently we don't emit
a relocation if VariantKind is VK_None (with few exceptions like RISC-V
relaxation), while GNU as emits one. This causes program behavior
differences with and without -ffunction-sections, and can break intended
symbol interposition in a -shared link.
```
.globl foo
foo:
call foo # no relocation. On other targets, may be written as b foo, etc
call bar # a relocation if bar is in another section (e.g. -ffunction-sections)
call foo at plt # a relocation
```
Unify these cases by always emitting a relocation. If we ever want to
optimize `call foo` in -shared links, we should emit a STB_LOCAL alias
and call via the alias.
ARM/thumb2-beq-fixup.s: we now emit a relocation to global_thumb_fn as GNU as does.
X86/Inputs/align-branch-64-2.s: we now emit R_X86_64_PLT32 to foo as GNU does.
ELF/relax.s: rewrite the test as target-in-same-section.s .
We omitted relocations to `global` and now emit R_X86_64_PLT32.
Note, GNU as does not emit a relocation for `jmp global` (maybe its own
bug). Our new behavior is compatible except `jmp global`.
Reviewed By: peter.smith
Differential Revision: https://reviews.llvm.org/D72197
More information about the All-commits
mailing list