This is an archive of the discontinued LLVM Phabricator instance.

[llvm-objcopy] New layout algorithm that lays out segments first
ClosedPublic

Authored by jakehehrlich on Aug 8 2017, 4:09 PM.

Details

Summary

The current file layout algorithm in llvm-objcopy is simple but difficult to reason about. It also makes it very complicated to support nested segments and to support segments that have offsets that come before a point after the program headers. To support these cases and simplify one of the most critical parts llvm-objcopy I rewrote the layout algorithm. Laying out segments first solves most of the issues encountered by the previous algorithm.

Diff Detail

Repository
rL LLVM

Event Timeline

jakehehrlich created this revision.Aug 8 2017, 4:09 PM
phosek edited edge metadata.Aug 22 2017, 1:10 PM

Just a few small nits but otherwise looks good to me.

tools/llvm-objcopy/Object.cpp
378 ↗(On Diff #110297)

nit: Space between if and paren.

393 ↗(On Diff #110297)

nit: s/segmnet/segment

jhenderson edited edge metadata.Aug 23 2017, 1:35 AM

I like this approach. Just a slight comment rephrasing needed from my point of view, apart from the nits.

tools/llvm-objcopy/Object.cpp
373 ↗(On Diff #110297)

Nit: capital letter

394–396 ↗(On Diff #110297)

Nit: full stop at end.

It's not clear to me whose original offset is being talked about in each of the two mentions here, please could you rephrase somehow.

Fixed comments by Petr and James

jakehehrlich marked 4 inline comments as done.Aug 23 2017, 1:26 PM
This revision is now accepted and ready to land.Aug 24 2017, 1:25 AM
This revision was automatically updated to reflect the committed changes.