Skip to content

[LLD][COFF] undefined section symbol is not being handled correctly #136235

Closed
@NikitaSmith057

Description

@NikitaSmith057

dll.c

__declspec(dllexport) void foo() {}

main.c

extern char __IMPORT_DESCRIPTOR_dll;
int main()
{
   // force linker to pull in archive member with undefined section symbols
   void *p = &__IMPORT_DESCRIPTOR_dll;
}

Build Steps

  1. cl /c dll.c
  2. link /dll dll.obj
  3. cl /c main.c
  4. lld-link dll.lib main.obj

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

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 and .idata$5.

...
004 C0000040 UNDEF  notype       Section      | .idata$4
005 C0000040 UNDEF  notype       Section      | .idata$5
...

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions