This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - Linkerscript: implement REGION_ALIAS.
ClosedPublic

Authored by grimar on Sep 5 2017, 8:07 AM.

Details

Summary

REGION_ALIAS(alias, region)

Alias names can be added to existing memory regions created with
the MEMORY command. Each name corresponds to at most one
memory region.

Used in many scripts that can be found in the wild.
Patch implements it.

Diff Detail

Repository
rL LLVM

Event Timeline

grimar created this revision.Sep 5 2017, 8:07 AM
grimar updated this revision to Diff 113862.Sep 5 2017, 8:16 AM
  • Updated testcase (added missing quote escapes).
ruiu added inline comments.Sep 5 2017, 10:48 AM
ELF/ScriptParser.cpp
403 ↗(On Diff #113862)

It'll eventually fail if you call setError, so don't worry too much about ErrorCount. I'd remove this if and execute the following line unconditionally.

1240–1242 ↗(On Diff #113862)

Does this work?

Script->Opt.MemoryRegions[Name] =
  make<MemoryRegion>(Name, Origin, Length, Flags, NegFlags);
grimar updated this revision to Diff 113972.Sep 6 2017, 2:26 AM
  • Addressed comments.
  • Formatted testcase to 80 columns.
ELF/ScriptParser.cpp
403 ↗(On Diff #113862)

Done.

1240–1242 ↗(On Diff #113862)

Nope. Error is: "'lld::elf::MemoryRegion::MemoryRegion': no overloaded function takes 5 arguments",
that is why I did not do that initially. I believe it will work if we add constructor taking these 5 to
MemoryRegion, but does not seems it really worth to do for me.

ruiu added inline comments.Sep 6 2017, 11:18 AM
ELF/ScriptParser.cpp
1240–1242 ↗(On Diff #113862)

Then how about this?

Script->Opt.MemoryRegions[Name] =
  make<MemoryRegion>({Name, Origin, Length, Flags, NegFlags});
grimar added inline comments.Sep 7 2017, 3:25 AM
ELF/ScriptParser.cpp
1240–1242 ↗(On Diff #113862)

That was first I tried initially, it will error out:
error C2660: 'lld::elf::make': function does not take 1 arguments

As I mentioned, with constructor taking this arguments it is possible to use

Script->Opt.MemoryRegions[Name] =
  make<MemoryRegion>(Name, Origin, Length, Flags, NegFlags);

Do you want me to add constructor ?

ruiu accepted this revision.Sep 7 2017, 12:20 PM

LGTM

ELF/ScriptParser.cpp
1240–1242 ↗(On Diff #113862)

Do you want me to add constructor ?

No, as it's not overall a win.

This revision is now accepted and ready to land.Sep 7 2017, 12:20 PM
This revision was automatically updated to reflect the committed changes.