[PATCH] D62317: [llvm-objcopy] - Strip undefined symbols if they are no longer referenced following --only-section
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri May 24 07:11:42 PDT 2019
grimar added a comment.
In D62317#1515541 <https://reviews.llvm.org/D62317#1515541>, @jhenderson wrote:
> I think you should do that before landing this, because it might mean the implementation is a little simpler (e.g. we simply always remove unreferenced undefined globals, regardless of the switch).
Ok, done: imagine we have
.globl bar
.globl foo
.section .text,"ax"
movl $bar, %edx
I.e. file with `.text`, `.rela.text`,
undefined `bar`, referenced by `.rela.text` and
undefined unreferenced `foo`.
(also, GNU `as` creates zero sized `.data` section, it is used below)
> as in.s -o as.o
GNU objdump behavior:
1. objcopy in.o out.o:
both `foo` and `bar` are in the output.
2. objcopy in.o out.o -R .text
`.text` and `.rela.text` are removed, both symbols are there.
3. objcopy in.o out.o -j .text -j .rela.text
reports error: objcopy: out.o: symbol `bar` required but not present
(looks like a bug to me)
4. objcopy in.o out.o -j .data
`.text` and `.rela.text` are removed, both symbols are removed.
I.e. the behavior of this patch matches GNU now,
which does not removes undefined unreferenced symbols when `-R` is used and
does not remove them regardless of the switch.
Is there anything else you think worth to check?
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D62317/new/
https://reviews.llvm.org/D62317
More information about the llvm-commits
mailing list