This is an archive of the discontinued LLVM Phabricator instance.

[ifs] Add --strip-size flag
ClosedPublic

Authored by abrachet on May 2 2022, 11:24 AM.

Details

Summary

st_size may not be of importance to the abi if you are not using copy relocations. This is helpful when you want to check the abi of a shared object both when instrumented and not because asan will increase the size of objects to include the redzone.

Diff Detail

Event Timeline

abrachet created this revision.May 2 2022, 11:24 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 2 2022, 11:25 AM
abrachet requested review of this revision.May 2 2022, 11:25 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 2 2022, 11:25 AM

I'd like to see an llvm-ifs Command Guide document wtitten sooner rather than later, since all llvm tools should have one. Please look at doing this soon.

llvm/lib/InterfaceStub/ELFObjHandler.cpp
222

Why is Size set to 1 and not 0, which would seem the more natural value?

llvm/test/tools/llvm-ifs/strip-size.test
8
llvm/tools/llvm-ifs/llvm-ifs.cpp
441

Could you make Sym.Size Optional instead? That would seem like a cleaner interface to me.

abrachet updated this revision to Diff 426743.May 3 2022, 9:21 AM
abrachet added a reviewer: jhenderson.
abrachet marked 3 inline comments as done.May 3 2022, 9:23 AM

I'd like to see an llvm-ifs Command Guide document wtitten sooner rather than later, since all llvm tools should have one. Please look at doing this soon.

Looks like @haowei already created it. Added documentation for --strip-size

llvm/lib/InterfaceStub/ELFObjHandler.cpp
222
llvm/tools/llvm-ifs/llvm-ifs.cpp
441

Sure

jhenderson added inline comments.May 4 2022, 1:32 AM
llvm/docs/CommandGuide/llvm-ifs.rst
198

It would be nice of this wording was made more consistent with other options in this file.

llvm/lib/InterfaceStub/ELFObjHandler.cpp
222

But giving a value of 1 means the relocation becomes invalid? It seems to me if you care about linker behaviour around copy relocations, you can't change their size at all.

llvm/lib/InterfaceStub/IFSHandler.cpp
120–121

This is a very weird thing to do in a function about writing YAML. Do you need to do it, and if so, do you need to do it here specifically?

abrachet updated this revision to Diff 428547.May 10 2022, 6:51 PM
abrachet marked 2 inline comments as done.
abrachet marked 3 inline comments as done.May 10 2022, 6:56 PM
abrachet added inline comments.
llvm/docs/CommandGuide/llvm-ifs.rst
198

Did my best, feel free to suggest something else.

llvm/lib/InterfaceStub/ELFObjHandler.cpp
222

You're right, I like the idea of failing fast when stripping size and using those stubs with non-pic

llvm/lib/InterfaceStub/IFSHandler.cpp
120–121

Indeed, I think I removed this in the first diff, but accidentally added it back in the second. Thanks

Three nits, but otherwise LGTM, with the caveat that I'm not a user or regular developer of this tool, so there might be some cases I haven't considered. If there's someone else available to sign off too, that would be good.

llvm/docs/CommandGuide/llvm-ifs.rst
201–202

Not sure if the "and" should be "or".

llvm/lib/InterfaceStub/IFSHandler.cpp
121–126
llvm/tools/llvm-ifs/llvm-ifs.cpp
440

I'd probably explicitly write out the type of Sym, since it is not obvious from this location (see the coding standards on use of auto).

abrachet updated this revision to Diff 429311.May 13 2022, 11:41 AM
abrachet marked 6 inline comments as done.
haowei accepted this revision.May 13 2022, 1:24 PM

Thanks for working on this.

This revision is now accepted and ready to land.May 13 2022, 1:24 PM
This revision was landed with ongoing or failed builds.May 14 2022, 10:26 AM
This revision was automatically updated to reflect the committed changes.
abrachet updated this revision to Diff 429474.May 14 2022, 11:49 AM

Fix unittests

This revision was landed with ongoing or failed builds.May 14 2022, 11:51 AM