Issue 136235
Summary [LLD][COFF] undefined section symbol is not being handled correctly
Labels lld
Assignees
Reporter NikitaSmith057
    ### dll.c
```C
__declspec(dllexport) void foo() {}
```
### main.c
 ```C
extern char __IMPORT_DESCRIPTOR_dll;
int main()
{
    // force linker to pull in archive member with undefined .idata$4 symbol
	void *p = &__IMPORT_DESCRIPTOR_dll;
}
```
### Build Steps
1. `cl /c dll.c`
2. `link dll.obj /dll`
3. `cl /c main.c`
4. `lld-link dll.lib main.obj`

Error: `lld-link: error: section larger than 4 GiB: .data`

Linking in step 2 with lld produces a different error: `lld-link: error: dll.lib(dll.dll): .idata$4 should not refer to special section 0`

I think lld misinterprets these symbols in dll.lib, the symbol values are actually section flags that linker is supposed to match with resolved .idata$4 section.
```
...
004 C0000040 UNDEF  notype       Section      | .idata$4
005 C0000040 UNDEF  notype       Section      | .idata$5
...
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to