[LLD][COFF] Allow overwriting directives exports with cmd-line exports
authorAlexandre Ganea <alex_toresh@yahoo.fr>
Tue, 13 Jun 2023 19:12:55 +0000 (15:12 -0400)
committerAlexandre Ganea <alex_toresh@yahoo.fr>
Tue, 13 Jun 2023 19:29:46 +0000 (15:29 -0400)
commitadcdc9cc3740adba3577b328fa3ba492cbccd3a5
tree1343d1e2530cd0ca4eeab11e2ae5ba858a857ac8
parent5360258bce6036a6801220fa1d11d172fa27e13b
[LLD][COFF] Allow overwriting directives exports with cmd-line exports

MSVC link.exe allows overriding exports on the cmd-line with exports seen in OBJ directives. The typical case is what is described in #62329.

Before this patch, trying to override an export with `/export` or `/def` would generate a duplicate warning. This patches tries to replicate the MSVC behavior. A second override on the cmd-line would still generate the warning.

There's still a case which we don't cover: MSVC link.exe is able to demangle an exported OBJ directive function, and match it with a unmangled export function in a .def file. In the meanwhile, one can use the mangled export in the .def to cover that case.

This fixes #62329

Differential revision: https://reviews.llvm.org/D149611
lld/COFF/Config.h
lld/COFF/DLL.cpp
lld/COFF/Driver.cpp
lld/COFF/DriverUtils.cpp
lld/test/COFF/export.test
lld/test/COFF/export32.test
lld/test/COFF/ordinals-override.test [new file with mode: 0644]