bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/30140] New: LD does not link PE executable with symbols from DEF


From: pali at kernel dot org
Subject: [Bug ld/30140] New: LD does not link PE executable with symbols from DEF file
Date: Sun, 19 Feb 2023 15:14:37 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=30140

            Bug ID: 30140
           Summary: LD does not link PE executable with symbols from DEF
                    file
           Product: binutils
           Version: 2.39
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: pali at kernel dot org
  Target Milestone: ---

Lets take simple test-library.dll with one exported function "func1". And try
to use it in test-executable.c. 

$ cat test-library.def
LIBRARY "test-library.dll"
EXPORTS
func1

$ cat test-executable.c
__attribute__((dllimport)) void func1(void);

int main() {
        func1();
        return 0;
}

If gcc is invoked directly with test-executable.c and test-library.def then LD
linker throws strange error and does not produce output executable file:

$ x86_64-w64-mingw32-gcc test-executable.c test-library.def -o
test-executable.exe
/usr/bin/x86_64-w64-mingw32-ld: cannot export func1: symbol not defined
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccx6dW5J.o:test-executabl:(.text+0x10):
undefined reference to `__imp_func1'
collect2: error: ld returned 1 exit status


If test-executable.c is linked with import library generated from
test-library.def then everything works fine and produce output executable file:

$ x86_64-w64-mingw32-dlltool -d test-library.def -l test-library.dll.a
$ x86_64-w64-mingw32-gcc test-executable.c test-library.dll.a -o
test-executable.exe


I think that this is an issue in LD because it should be able to handle DEF
file correctly. Or if LD does not support DEF files then it should throw
meaningful human readable error. Not that "symbol not defined" because it *is*
defined in test-library.def file.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]