bug-binutils
[Top][All Lists]
Advanced

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

[Bug ld/30144] New: LD --entry does not accept function name


From: pali at kernel dot org
Subject: [Bug ld/30144] New: LD --entry does not accept function name
Date: Sun, 19 Feb 2023 17:16:32 +0000

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

            Bug ID: 30144
           Summary: LD --entry does not accept function name
           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: ---

NT kernel drivers have as entry point function DriverEntry with stdcall calling
convension. Compiling NT kernel drivers via GCC/LD would be lot of easier if LD
supports specifying entry point as function name as opposite of the mangled
symbol name, which is DriverEntry for AMD64 and _DriverEntry@8 for IX86.

$ cat test-entry.c
__attribute__((stdcall))
long DriverEntry(void *DriverObject, void *RegistryPath) {
        return 0;
}

$ x86_64-w64-mingw32-gcc -nostartfiles -nodefaultlibs -nostdlib
-Wl,--subsystem,native -Wl,--entry=DriverEntry test-entry.c -o test-entry.sys
(compiles fine, no warning/error)

$ i686-w64-mingw32-gcc -nostartfiles -nodefaultlibs -nostdlib
-Wl,--subsystem,native -Wl,--entry=DriverEntry test-entry.c -o test-entry.sys
/usr/bin/i686-w64-mingw32-ld: warning: cannot find entry symbol DriverEntry;
defaulting to 00401000
(entry point is completely ignored and replaced by some random address)

$ i686-w64-mingw32-gcc -nostartfiles -nodefaultlibs -nostdlib
-Wl,--subsystem,native -Wl,--entry=_DriverEntry@8 test-entry.c -o
test-entry.sys
(compiles fine, no warning/error)

As can be seen in the above example, for every architecture it is needed to
pass correctly mangled symbol name into LD --entry argument. It would really
help if LD tries to represent --entry argument as function name and mangle it
to guess symbol name. As currently it is not possible to specify compile
parameters which would work for all architectures universally.

-- 
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]