[COFF] Link crtend.o as the last object file
authorMartin Storsjo <martin@martin.st>
Mon, 15 Apr 2019 10:57:44 +0000 (10:57 +0000)
committerMartin Storsjo <martin@martin.st>
Mon, 15 Apr 2019 10:57:44 +0000 (10:57 +0000)
commitcdf126ebec185d135dfb99cb907cf4f40583e3dc
tree26c851b7a608cb5063b75169eecd748a988b1820
parent7844031d460403596f151c30068d7fe062d92b37
[COFF] Link crtend.o as the last object file

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 moves crtend.o
to the end of the vector of object files. This makes sure that
terminator chunks for sections such as .eh_frame gets ordered last,
fixing DWARF exception handling for libgcc and gcc's crtend.o.

Differential Revision: https://reviews.llvm.org/D60628

llvm-svn: 358394
lld/COFF/Driver.cpp
lld/docs/ReleaseNotes.rst
lld/test/COFF/Inputs/eh_frame_terminator-crtend.s [new file with mode: 0644]
lld/test/COFF/Inputs/eh_frame_terminator-otherfunc.s [new file with mode: 0644]
lld/test/COFF/eh_frame_terminator.s [new file with mode: 0644]