[PATCH] D60628: [LLD] [COFF] Link crtend.o as the last object file

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 12 12:08:22 PDT 2019


mstorsjo created this revision.
mstorsjo added reviewers: ruiu, rnk, pcc.
Herald added a subscriber: aprantl.
Herald added a project: LLVM.

When faced with command line options such as "crtbegin.o appmain.o -lsomelib crtend.o", GNU ld pulls in all necessary object files from somelib before proceeding to crtend.o.

LLD operates differently, only loading object files from any referenced static libraries after processing all input object files.

This uses a similar hack as in the ELF linker. Here, it makes sure that crtend.o gets added last, so that terminator chunks for sections such as .eh_frame gets ordered last, fixing DWARF exception handling for libgcc and gcc's crtend.o.

I copied the function for identifying the crtend object file from the ELF linker - should that maybe be moved to some shared file?


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D60628

Files:
  COFF/Driver.cpp
  docs/ReleaseNotes.rst
  test/COFF/Inputs/eh_frame_terminator-crtend.s
  test/COFF/Inputs/eh_frame_terminator-otherfunc.s
  test/COFF/eh_frame_terminator.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60628.194930.patch
Type: text/x-patch
Size: 4006 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190412/603a399a/attachment.bin>


More information about the llvm-commits mailing list