This is an archive of the discontinued LLVM Phabricator instance.

ELF2: LinkerScript: lookup absolute paths under sysroot
ClosedPublic

Authored by atanasyan on Nov 23 2015, 3:00 AM.

Details

Summary

In case a sysroot prefix is configured, and the filename starts with the '/' character, and the script being processed was located inside the sysroot prefix, the file's name will be looked for in the sysroot prefix. Otherwise, the linker falls to the common lookup scheme.

https://www.sourceware.org/binutils/docs-2.24/ld/File-Commands.html

Diff Detail

Repository
rL LLVM

Event Timeline

atanasyan updated this revision to Diff 40909.Nov 23 2015, 3:00 AM
atanasyan retitled this revision from to ELF2: LinkerScript: lookup absolute paths under sysroot.
atanasyan updated this object.
atanasyan added a reviewer: ruiu.
atanasyan set the repository for this revision to rL LLVM.
atanasyan added a project: lld.
atanasyan added a subscriber: llvm-commits.
emaste added a subscriber: emaste.Nov 23 2015, 8:05 AM
emaste added a subscriber: davide.Nov 23 2015, 8:08 AM
ruiu added inline comments.Nov 23 2015, 10:17 AM
ELF/Driver.h
59 ↗(On Diff #40909)

Can you use MemoryBufferRef::getBufferIdentifier() instead of Path?

ELF/LinkerScript.cpp
31 ↗(On Diff #40909)

"bool B" for consistency.

167 ↗(On Diff #40909)

Can you separate this into two lines?

SmallString<128> Path;
(Config->Sysroot + S).toStringRef(Path);
if (sys::fs::exists(Path))
  S = Path;
306–307 ↗(On Diff #40909)
LinkerScript(A, MB.getBuffer(), true).run();
return;
309 ↗(On Diff #40909)
LinkerScript(A, MB.getBuffer(), false).run();
atanasyan updated this revision to Diff 41008.Nov 23 2015, 10:59 PM
  • Use MemoryBufferRef::getBufferIdentifier() to get a path to the linker script
  • Fix code formatting issues mentioned on the review
ruiu accepted this revision.Nov 24 2015, 10:32 AM
ruiu edited edge metadata.

LGTM

This revision is now accepted and ready to land.Nov 24 2015, 10:32 AM
This revision was automatically updated to reflect the committed changes.