This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - Linkerscript: accept integer values for PHDRS types.
ClosedPublic

Authored by grimar on Oct 13 2016, 3:16 AM.

Details

Summary

Found that in the wild. Both gold and ld accepts integers instead of named constants
for PHDRS. For example older OpenBSD code had:
(https://lab.knightsofnii.com/kristaba/openbsd/blob/4a75b1afc24240f0320911070f95ddf644b8cac7/sys/arch/amd64/conf/kern.ldscript)

PHDRS
{
....
	openbsd_randomize 0x65a3dbe6; /* PT_OPENBSD_RANDOMIZE */
}

Patch adds support for that.

Diff Detail

Repository
rL LLVM

Event Timeline

grimar updated this revision to Diff 74484.Oct 13 2016, 3:16 AM
grimar retitled this revision from to [ELF] - Linkerscript: accept integer values for PHDRS types..
grimar updated this object.
grimar added reviewers: ruiu, rafael.
grimar added subscribers: llvm-commits, grimar, evgeny777.
ruiu added inline comments.Oct 13 2016, 10:48 AM
ELF/LinkerScript.cpp
1711–1714 ↗(On Diff #74484)

Just return Ret here.

if (readInteger(Tok, Ret))
  return Ret;
test/ELF/linkerscript/phdrs.s
52 ↗(On Diff #74484)

I don't see a reason to have three test cases here. One pattern should suffice.

grimar updated this revision to Diff 74665.Oct 14 2016, 5:55 AM
  • Addressed review comments.
ELF/LinkerScript.cpp
1711–1714 ↗(On Diff #74484)

readInteger() takes uint64, so looks better to have Val also.

test/ELF/linkerscript/phdrs.s
52 ↗(On Diff #74484)

Ok.

ruiu accepted this revision.Oct 17 2016, 11:17 AM
ruiu edited edge metadata.

LGTM

ELF/LinkerScript.cpp
1709 ↗(On Diff #74665)

Add a comment.

// Read a program header type name. The next token must be a
// name of a program header type or a constant (e.g. "0x3").
This revision is now accepted and ready to land.Oct 17 2016, 11:17 AM
This revision was automatically updated to reflect the committed changes.