This is an archive of the discontinued LLVM Phabricator instance.

[ELF2] --strip-all/-s command line implemented
ClosedPublic

Authored by grimar on Oct 21 2015, 4:13 AM.

Details

Summary

-s, --strip-all - Strip all symbols
Implementation removes .strtab and .symtab sections from output.

Test from lld\test\elf branch was taken as a base, but was improved in part of checks.

Diff Detail

Repository
rL LLVM

Event Timeline

grimar updated this revision to Diff 37984.Oct 21 2015, 4:13 AM
grimar retitled this revision from to [ELF2] --strip-all/-s command line implemented.
grimar updated this object.
grimar added reviewers: ruiu, rafael, davide.
grimar added subscribers: llvm-commits, grimar.
ruiu added inline comments.Oct 21 2015, 5:23 AM
ELF/Writer.cpp
113–115 ↗(On Diff #37984)

This is a bit confusing. Let's do this

std::unique_ptr<SymbolTableSection<ELFT>> SymTab;
if (!Config->StripAll) {
  SymTab.reset(new SymbolTableSection<ELFT>(*Symtab, *Out<ELFT>::StrTab);
  Out<ELFT>::SymTab = SymTab.get();
}
grimar added inline comments.Oct 21 2015, 7:11 AM
ELF/Writer.cpp
113–115 ↗(On Diff #37984)

I thought about something like that, just didn`t know will it keep code consistency or not. I agree, that will be better.

btw, the same can be applied for RelaPlt and GotPlt since we dont need to create them when lazy relocs are off. (not for this patch)

davide edited edge metadata.Oct 21 2015, 8:45 AM

Structure looks good, just few comments.

ELF/Config.h
59 ↗(On Diff #37984)

This is not sorted.

ELF/Options.td
86 ↗(On Diff #37984)

Can't you just say "strip all symbols" as gold and ld do?

test/elf2/strip-all.s
1 ↗(On Diff #37984)

Please do not use obj2yaml, but use assembler for tests. This is the standard for the new ELF linker.

grimar added inline comments.Oct 21 2015, 9:10 AM
ELF/Config.h
59 ↗(On Diff #37984)

Will fix.
I forgot that after first two characters there are still other ones, sorry :)

ELF/Options.td
86 ↗(On Diff #37984)

I took it from man ld, but will replace if you wish.

test/elf2/strip-all.s
1 ↗(On Diff #37984)

Ok. I expected that. Thats explains why I never saw its usings in new ELF branch.

davide added inline comments.Oct 21 2015, 9:13 AM
ELF/Options.td
86 ↗(On Diff #37984)

This is what I see on FreeBSD. I would not deviate from that as it's shorter and captures the essence anyway (which I think is better for --help output)
davide@ganondorf:~ % /usr/local/bin/ld.bfd --help | grep strip-all

-s, --strip-all             Strip all symbols

davide@ganondorf:~ % /usr/local/bin/ld.gold --help | grep strip-all

-s, --strip-all             Strip all symbols

Thanks,

Davide

grimar updated this revision to Diff 38253.Oct 23 2015, 1:04 PM
grimar edited edge metadata.

Review comments addressed.

ruiu accepted this revision.Oct 23 2015, 1:08 PM
ruiu edited edge metadata.

LGTM

This revision is now accepted and ready to land.Oct 23 2015, 1:08 PM
This revision was automatically updated to reflect the committed changes.