This is an archive of the discontinued LLVM Phabricator instance.

[ELF2/Linkerscript] Skip semicolon in linker directives parsing
ClosedPublic

Authored by davide on Oct 13 2015, 11:33 AM.

Details

Summary

According to docs, semicolons are mandatory at the end of assignment but they're allowed/optional in directives. I found an example of that in a FreeBSD linker script. I'll change the linker script in FreeBSD to remove the semicolon but I think it's good we support this for GNU ld compatibility.

Diff Detail

Repository
rL LLVM

Event Timeline

davide updated this revision to Diff 37277.Oct 13 2015, 11:33 AM
davide retitled this revision from to [ELF2/Linkerscript] Skip semicolon in linker directives parsing.
davide updated this object.
davide added reviewers: ruiu, rafael.
davide set the repository for this revision to rL LLVM.
davide added a subscriber: llvm-commits.
ruiu edited edge metadata.Oct 13 2015, 11:47 AM

LGTM with a nit.

https://sourceware.org/binutils/docs/ld/Script-Format.html says that "You may separate commands using semicolons", so it seems optional. Probably single ';' at beginning of file is valid because of the same reason that empty statement is accepted in C.

ELF/LinkerScript.cpp
62–65 ↗(On Diff #37277)
if (Tok == ";")
  continue;
if (Tok == "ENTRY") {
This revision was automatically updated to reflect the committed changes.