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

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
1727–1728

Just return Ret here.

if (readInteger(Tok, Ret))
  return Ret;
test/ELF/linkerscript/phdrs.s
52

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
1727–1728

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

test/ELF/linkerscript/phdrs.s
52

Ok.

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

LGTM

ELF/LinkerScript.cpp
1709

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.