This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Implement parsing `-l` prefixed items in the `GROUP` linker script command
ClosedPublic

Authored by atanasyan on Jul 10 2014, 10:37 PM.

Details

Summary

Implement parsing -l prefixed items in the GROUP linker script command. There are two forms of -l prefixed expression:

  • -l<libname>
  • -l:<filename>

In the first case a linker should construct a full library name lib + libname + .[so|a] and search this library as usual. In the second case a linker should use the <filename> as is and search this file through library search directories.

Diff Detail

Event Timeline

atanasyan updated this revision to Diff 11308.Jul 10 2014, 10:37 PM
atanasyan retitled this revision from to [ELF] Implement parsing `-l` prefixed items in the `GROUP` linker script command.
atanasyan updated this object.
atanasyan edited the test plan for this revision. (Show Details)
atanasyan added reviewers: Bigcheese, shankarke, ruiu.
atanasyan added a subscriber: Unknown Object (MLST).
shankarke requested changes to this revision.Jul 11 2014, 7:33 AM
shankarke edited edge metadata.
shankarke added inline comments.
include/lld/ReaderWriter/LinkerScript.h
76

Should this be a ErrorOr<StringRef::size_type> ?

76

const.

76

Do we have a test that covers the error case ?

lib/ReaderWriter/ELF/ELFLinkingContext.cpp
169

aName=> archiveName ?

lib/ReaderWriter/LinkerScript.cpp
127

raise an error here.

210

I think we need canStartLibraryName, as canStartName returns true for cases where a library name would be invalid.

For example the below cases.

case '_': case '.': case '$': case '/': case '\\':
  return true;

We should reject invalid library names IMO

216

error here ?

This revision now requires changes to proceed.Jul 11 2014, 7:33 AM
atanasyan updated this revision to Diff 11374.Jul 14 2014, 6:37 AM
atanasyan edited edge metadata.
  • Fixed all minor problems line const qualifiers, local variable naming etc.
  • Made the code which handles a library name -l shorter and more similar to the code handles a regular file names.
  • Keep using the unknown token to indicate an unexpected input. The same approach is used by other parts of the lexer now.
  • Added some new test cases.
  • I decided to do not introduce new routines like canStartLibraryName to validate library names. Anyway we check this name later and report an error if this name is invalid. It is better than reject a valid name here by mistake. By the way BFD and Gold linker accept almost arbitrary names.
shankarke accepted this revision.Jul 14 2014, 6:58 AM
shankarke edited edge metadata.
This revision is now accepted and ready to land.Jul 14 2014, 6:58 AM
atanasyan closed this revision.Jul 15 2014, 10:27 AM

Thanks for review.

Closed by commit rL213077.