This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - Implemented --section-start, -Ttext, -Tdata, -Tbss options.
ClosedPublic

Authored by grimar on Sep 7 2016, 6:56 AM.

Details

Summary

This is PR30269,

These options defined as:

--section-start=sectionname=org
Locate a section in the output file at the absolute address given by org. You may use this option as many times as necessary to locate multiple sections in the command line. org must be a single hexadecimal integer; for compatibility with other linkers, you may omit the leading `0x' usually associated with hexadecimal values. Note: there should be no white space between sectionname, the equals sign (“<=>”), and org.

-Tbss=org
-Tdata=org
-Ttext=org
Same as --section-start, with .bss, .data or .text as the sectionname.

Diff Detail

Repository
rL LLVM

Event Timeline

grimar updated this revision to Diff 70529.Sep 7 2016, 6:56 AM
grimar retitled this revision from to [ELF] - Implemented --section-start, -Ttext, -Tdata, -Tbss options..
grimar updated this object.
grimar added reviewers: ruiu, rafael.
grimar added subscribers: llvm-commits, grimar, evgeny777, emaste.
ruiu added inline comments.Sep 7 2016, 2:59 PM
ELF/Config.h
67 ↗(On Diff #70529)

This is not a list but a map.

ELF/Driver.cpp
375 ↗(On Diff #70529)

read -> parse to be consistent with parseEmulation.

380 ↗(On Diff #70529)
-Ttext: " + S);
384–385 ↗(On Diff #70529)

Remove llvm::.

393–398 ↗(On Diff #70529)
if (auto *Arg = Args.getLastArg(...))
  Ret[...] = readSectionAddress(Arg->getValue());
grimar updated this revision to Diff 70659.Sep 8 2016, 1:46 AM
  • Addressed review comments.
ELF/Config.h
67 ↗(On Diff #70529)

Done.

ELF/Driver.cpp
375 ↗(On Diff #70529)

Done.

380 ↗(On Diff #70529)

Done. I did not do this initially because it does not catch everything. Ex:

--section-start ABCDF

ABCDF does not contain '=', and S will be empty, resulting message " ... -Ttext: ".
Was not sure if that worth to add initial expression as argument or do something for that case.

384–385 ↗(On Diff #70529)

Done.

393–398 ↗(On Diff #70529)

Done.

ruiu added inline comments.Sep 8 2016, 9:14 AM
ELF/Driver.cpp
380 ↗(On Diff #70659)

Please do whatever to make it user friendly.

grimar updated this revision to Diff 70961.Sep 11 2016, 1:39 AM
  • Reworked error reporting.
ELF/Driver.cpp
380 ↗(On Diff #70659)

Well if I would be user, I would be happy to see a detailed message and not the common, so to make it more user friendly I would probably suggest to split reporting.
That also helps to keep code a bit more clean because --section-start as handled a bit differently from other 3 options.
Updated the patch, what do you think ?

ruiu added inline comments.Sep 12 2016, 1:42 PM
ELF/Driver.cpp
382 ↗(On Diff #70961)

So I think you want to pass opt::Arg *Arg as the second argument, and

387 ↗(On Diff #70961)

do

error("invalid argument: " + stringize(Arg));
403–405 ↗(On Diff #70961)

This doesn't look very beautiful.

grimar updated this revision to Diff 71153.Sep 13 2016, 6:04 AM
  • addressed review comments.
ELF/Driver.cpp
387 ↗(On Diff #70961)

I did not know about stringnize(). Thank you for hint.

403–405 ↗(On Diff #70961)

Fixed. What personally I do not like here is a way how clang-format works.
In modern time I do not like to see code formatted to the 1/3 of my screen width at left. That is how the result looks for me now though.

grimar added inline comments.Sep 13 2016, 6:09 AM
ELF/Driver.cpp
403–405 ↗(On Diff #71153)

I find what clang-format do is ugly sometimes. And what it did for previous revision of this was ugly, but I was unable to change that. That is what I meant.

ruiu accepted this revision.Sep 13 2016, 1:44 PM
ruiu edited edge metadata.

LGTM with a nit.

ELF/Options.td
170–181 ↗(On Diff #71153)

Move the new definitions before allow_multiple_definition. They are sorted in ASCIIbetical order.

This revision is now accepted and ready to land.Sep 13 2016, 1:44 PM
This revision was automatically updated to reflect the committed changes.