llvm-project/lld/COFF
Nico Weber af6bc65ddf lld-link: Reject more than one resource .obj file
Users are exepcted to pass all .res files to the linker, which then
merges all the resource in all .res files into a tree structure and then
converts the final tree structure to a .obj file with .rsrc$01 and
.rsrc$02 sections and then links that.

If the user instead passes several .obj files containing such resources,
the correct thing to do would be to have custom code to merge the trees
in the resource sections instead of doing normal section merging -- but
link.exe rejects if multiple resource obj files are passed in with
LNK4078, so let lld-link do that too instead of silently writing broken
.rsrc sections in that case.

The only real way to run into this is if users manually convert .res
files to .obj files by running cvtres and then handing the resulting
.obj files to lld-link instead, which in practice likely never happens.

(lld-link is slightly stricter than link.exe now: If link.exe is passed
one .obj file created by cvtres, and a .res file, for some reason it
just emits a warning instead of an error and outputs strange looking
data. lld-link now errors out on mixed input like this.)

One way users could accidentally run into this is the following
scenario: If a .res file is passed to lib.exe, then lib.exe calls
cvtres.exe on the .res file before putting it in the output .lib.
(llvm-lib currently doesn't do this.)
link.exe's /wholearchive seems to only add obj files referenced from the
static library index, but lld-link current really adds all files in the
archive. So if lld-link /wholearchive is used with .lib files produced
by lib.exe and .res files were among the files handed to lib.exe, we
previously silently produced invalid output, but now we error out.

link.exe's /wholearchive semantics on the other hand mean that it
wouldn't load the resource object files from the .lib file at all.
Since this scenario is probably still an unlikely corner case,
the difference in behavior here seems fine -- and lld-link might have to
change to use link.exe's /wholearchive semantics in the future anyways.

Vaguely related to PR42180.

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

llvm-svn: 363078
2019-06-11 15:22:28 +00:00
..
CMakeLists.txt [LLD][COFF] Early dependency detection 2019-04-01 13:36:59 +00:00
Chunks.cpp [COFF] Add ImportChunkThunk, simplify, deduplicate 2019-05-28 17:38:04 +00:00
Chunks.h [COFF] Add ImportChunkThunk, simplify, deduplicate 2019-05-28 17:38:04 +00:00
Config.h [LLD][COFF] Implement /filealign parameter 2019-05-24 12:42:36 +00:00
DLL.cpp [COFF] De-virtualize Chunk and SectionChunk 2019-05-24 20:25:40 +00:00
DLL.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
DebugTypes.cpp [LLD][COFF] Don't take into account the 'age' when looking for PDB type server 2019-06-05 02:01:43 +00:00
DebugTypes.h Re-land [LLD][COFF] Early load PDB type server files 2019-06-03 12:39:47 +00:00
Driver.cpp lld-link: Reject more than one resource .obj file 2019-06-11 15:22:28 +00:00
Driver.h llvm-lib: Implement /machine: argument 2019-06-11 01:13:41 +00:00
DriverUtils.cpp lld-link: Reject more than one resource .obj file 2019-06-11 15:22:28 +00:00
ICF.cpp Re-land r361206 "[COFF] Store alignment in log2 form, NFC" 2019-05-22 20:21:52 +00:00
ICF.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
InputFiles.cpp lld-link: Reject more than one resource .obj file 2019-06-11 15:22:28 +00:00
InputFiles.h lld-link: Reject more than one resource .obj file 2019-06-11 15:22:28 +00:00
LTO.cpp Fix names of functions in TargetOptionsCommandFlags.h. NFC. 2019-02-01 02:24:50 +00:00
LTO.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
MapFile.cpp Re-land r361206 "[COFF] Store alignment in log2 form, NFC" 2019-05-22 20:21:52 +00:00
MapFile.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
MarkLive.cpp [COFF] Reduce the size of Chunk and SectionChunk, NFC 2019-04-02 22:11:58 +00:00
MarkLive.h [COFF] Delete unused declarations and add a missing forward declaration. NFC 2019-03-15 09:40:03 +00:00
MinGW.cpp Move MinGW-specific code out of LinkerDriver::link. NFC. 2019-02-19 22:06:44 +00:00
MinGW.h Move MinGW-specific code out of LinkerDriver::link. NFC. 2019-02-19 22:06:44 +00:00
Options.td [COFF] Add an lld specific option /includeoptional 2019-06-08 18:26:18 +00:00
PDB.cpp [PDB] Copy inlinee lines records into the PDB 2019-06-03 18:15:38 +00:00
PDB.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
README.md Update the documents of the new LLD. 2016-03-12 06:06:40 +00:00
SymbolTable.cpp llvm-lib: Implement /machine: argument 2019-06-11 01:13:41 +00:00
SymbolTable.h [COFF] Fix /export:foo=bar when bar is a weak alias 2019-06-07 22:05:12 +00:00
Symbols.cpp [COFF] Pack Name in Symbol as is done in ELF 2019-04-19 22:51:49 +00:00
Symbols.h [COFF] Pack Name in Symbol as is done in ELF 2019-04-19 22:51:49 +00:00
TypeMerger.h [LLD][COFF] Move type merging structures out of PDB.cpp. NFC 2019-04-02 20:43:19 +00:00
Writer.cpp Wrap comment to 80 columns 2019-06-11 01:14:23 +00:00
Writer.h [LLD][COFF] Generate import modules & COFF groups in PDB 2019-03-29 20:25:34 +00:00

README.md

See docs/NewLLD.rst