This is https://bugs.llvm.org/show_bug.cgi?id=40004.
In this patch I teach llvm-objcopy to remove undefined symbols if
them are not used anymore after applying -j/--only-section option.
Differential D62317
[llvm-objcopy] - Strip undefined symbols if they are no longer referenced following --only-section grimar on May 23 2019, 7:34 AM. Authored by
Details This is https://bugs.llvm.org/show_bug.cgi?id=40004. In this patch I teach llvm-objcopy to remove undefined symbols if
Diff Detail Event TimelineComment Actions The behaviour you've implemented removes all unreferenced symbols, even if they weren't previously referenced. Is this wise? Also, have you experimented with other stripping options, e.g. removing a section which references a symbol? The bug used --only-section, but there might be other similar cases.
Comment Actions
This behavior follows GNU, i think it is probably OK. Do you think we should change it?
Not yet, but that was my plan (after landing this). I was not going to close the bug before testing
Comment Actions Oh and I also added a test for "The behaviour you've implemented removes all unreferenced symbols, even if they weren't previously referenced" Comment Actions No, if it follows GNU, keep it as is.
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).
Comment Actions Ok, done: imagine we have .globl bar .globl foo .section .text,"ax" movl $bar, %edx I.e. file with .text, .rela.text,
GNU objdump behavior:
both foo and bar are in the output.
.text and .rela.text are removed, both symbols are there.
reports error: objcopy: out.o: symbol bar required but not present
.text and .rela.text are removed, both symbols are removed. I.e. the behavior of this patch matches GNU now, Is there anything else you think worth to check? Comment Actions Nope, what you've done seems fine to me. Please just address my inline comments. Note: I am away from the end of work today, for a week. I'm happy for somebody else to approve if my points are addressed.
Comment Actions
|
Maybe worth removing "only-section" from the test title, as I think it would make sense for other options to fall under this test too.