diff options
author | Oleg Tolmatcev <oleg.tolmatcev@gmail.com> | 2024-01-19 15:02:45 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2024-01-19 15:02:45 +0000 |
commit | d544a1dca23469d212e7e9edc754487352c5f042 (patch) | |
tree | 287c5ef174a1c8f10a6812051803fe596b194790 /ld | |
parent | f530d5f1bab6eb5adc65f422ef811fb278a21a4b (diff) | |
download | gdb-d544a1dca23469d212e7e9edc754487352c5f042.zip gdb-d544a1dca23469d212e7e9edc754487352c5f042.tar.gz gdb-d544a1dca23469d212e7e9edc754487352c5f042.tar.bz2 |
ld: fix 32-bit mingw DLL symbol export bug
I think there's a bug in ld on 32-bit Windows. Here is a tiny project for reproducing the problem:
https://github.com/oltolm/ld-mingw32-bug
A 32-bit DLL exports two stdcall functions "myfunc" and "myfunc64". The functions would normally get
exported as "myfunc@0" and "myfunc64@0". The "DEF" file exports them as "myfunc" and "myfunc64"
without the decorations. When you run the executable it shows an error message saying that it cannot
find "myfunc64".
I think it happens because the sorting in ld is wrong. I think it should use the exported names
"myfunc" and "myfunc64", but instead it uses the decorated names "myfunc@0" or "myfunc65@0". The
ordering of functions in the DLL is different depending on which names you use.
My patch changes ld to use undecorated exported names for sorting and it seems to fix the problem.
When I execute ctest in my project, it runs successfully.
Diffstat (limited to 'ld')
-rw-r--r-- | ld/deffilep.y | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/ld/deffilep.y b/ld/deffilep.y index 4967ff1..fb12e6d 100644 --- a/ld/deffilep.y +++ b/ld/deffilep.y @@ -610,12 +610,11 @@ cmp_export_elem (const def_file_export *e, const char *ex_name, { int r; - if ((r = are_names_equal (ex_name, e->name)) != 0) + if ((r = are_names_equal (its_name ? its_name : ex_name, + e->its_name ? e->its_name : e->name)) != 0) return r; if ((r = are_names_equal (in_name, e->internal_name)) != 0) return r; - if ((r = are_names_equal (its_name, e->its_name)) != 0) - return r; return (ord - e->ordinal); } |