bug-binutils
[Top][All Lists]
Advanced

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

[Bug binutils/30139] New: Incorrect ordinal numbers for aliased symbols


From: pali at kernel dot org
Subject: [Bug binutils/30139] New: Incorrect ordinal numbers for aliased symbols in DEF file
Date: Sun, 19 Feb 2023 14:11:20 +0000

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

            Bug ID: 30139
           Summary: Incorrect ordinal numbers for aliased symbols in DEF
                    file
           Product: binutils
           Version: 2.39
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: binutils
          Assignee: unassigned at sourceware dot org
          Reporter: pali at kernel dot org
  Target Milestone: ---

DEF file can contain alias for some symbol via == operator. But if such aliased
symbol is used in the code then binutils generates wrong ordinal symbol in PE
import table.

Below is simple example to demonstrate this issue.

Lets to have simple library library.dll.dll which has only one function "void
function(void)" under exported symbol "function" and also under exported
ordinal number 1. So DEF file for this library is:

LIBRARY "library.dll"
EXPORTS
function @1

If application wants to call this function() under name alias() then into DEF
file is added alias line:

alias == function

And using either to alias() or to function() would result in the same call.

But binutils/dlltool has issue and for alias() generates wrong ordinal number
and moreover generates two export symbols for function(). It can be seen in
objdump output.

$ x86_64-w64-mingw32-dlltool -V
GNU x86_64-w64-mingw32-dlltool (GNU Binutils) 2.39.90.20230110
Copyright (C) 2023 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) any later version.
This program has absolutely no warranty.

$ cat library.def
LIBRARY "library.dll"
EXPORTS
function @1
alias == function

$ cat test-ordinal.c
__attribute__((dllimport)) void function(void);
__attribute__((dllimport)) void alias(void);

int main() {
        function();
        alias();
        return 0;
}

$ x86_64-w64-mingw32-dlltool -d library.def -l library.dll.a

$ x86_64-w64-mingw32-gcc test-ordinal.c library.dll.a -o test-ordinal.exe

$ x86_64-w64-mingw32-objdump -p test-ordinal.exe | grep -A 4 library.dll
        DLL Name: library.dll
        vma:  Hint/Ord Member-Name Bound-To
        84e6        2  function
        84f2        1  function


As can be seen in defined library.def file, in "library.dll" there is no symbol
with ordinal number 2 and symbol "function" has ordinal number 1.

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