D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 18798 - ld.gold: relocation R_386_GOTOFF against preemptible symbol cannot be used when making a shared object
Summary: ld.gold: relocation R_386_GOTOFF against preemptible symbol cannot be used wh...
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Linux
: P3 normal
Assignee: No Owner
URL:
Keywords: dll, link-failure
Depends on:
Blocks:
 
Reported: 2018-04-25 12:45 UTC by Marco Leise
Modified: 2024-12-13 18:58 UTC (History)
1 user (show)

See Also:


Attachments
small reproduction case for the linker error (102 bytes, text/x-dsrc)
2018-04-28 13:38 UTC, Marco Leise
Details

Note You need to log in before you can comment on or make changes to this issue.
Description Marco Leise 2018-04-25 12:45:53 UTC
When linking a 32-bit shared library with dmd and ld.gold on Linux the linker bails out with:

/usr/x86_64-pc-linux-gnu/bin/ld: error: libgtkd-3.o: relocation R_386_GOTOFF against preemptible symbol _D3gtk9UIManagerQk9getWidgetMFAyaZCQBh6WidgetQh cannot be used when making a shared object
/usr/x86_64-pc-linux-gnu/bin/ld: error: libgtkd-3.o: relocation R_386_GOTOFF against preemptible symbol _D3std3uni__T21genericDecodeGraphemeVbi0Z__TQBfTAxaZQBnFNaNfKQnZv cannot be used when making a shared object
/usr/x86_64-pc-linux-gnu/bin/ld: error: libgtkd-3.o: relocation R_386_GOTOFF against preemptible symbol _D3std3uni__T21genericDecodeGraphemeVbi0Z__TQBfTAxaZQBnFNaNfKQnZv cannot be used when making a shared object

Using ldc2 or gdc as compilers it seems to work, so I assume it is a dmd backend issue. Just the other day a bug in ld.gold got fixed that prevented --ifc=safe to work (e.g. when self-hosting ldc2), --gc-sections got fixed in dmd earlier and this is now the only remaining linker compatibility issue I see on Linux.
Comment 1 Marco Leise 2018-04-28 13:38:57 UTC
Created attachment 1689 [details]
small reproduction case for the linker error

I attached a test case that can be compiled with dmd 2.079.1 like this:

    dmd -m32 -shared -fPIC -defaultlib=phobos2 reprocase.d

ld.gold has to be your default linker, otherwise you need to split compilation and linking:

    dmd -m32 -fPIC -c reprocase.d
    ld.gold -shared reprocase.o

What I found interesting about the test case is that it happens when you create a sufficiently complex switch-case. Remove one case and the error is gone. Could it be a bug in jump table generation on x86/PIC ?
Comment 2 Marco Leise 2018-04-28 13:43:14 UTC
My guess was hitting close:

    https://github.com/dlang/dmd/blob/1a05f4413ac6daaa8ae000dbe7399a302e3fc16b/src/dmd/backend/cod3.c#L1360

Above three cases a different code path is chosen in the back-end.
Comment 3 Walter Bright 2020-05-16 05:49:25 UTC
Can you show a piece of DMD code that, when compiled, uses a different location than GDC does (or even gcc) ?
Comment 4 dlangBugzillaToGithub 2024-12-13 18:58:29 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/19427

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB