D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 11406 - ld.gold breaks switch table jumps
Summary: ld.gold breaks switch table jumps
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 critical
Assignee: No Owner
URL:
Keywords: link-failure, pull
: 11492 (view as issue list)
Depends on:
Blocks:
 
Reported: 2013-10-31 20:39 UTC by Martin Nowak
Modified: 2015-06-09 05:11 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Martin Nowak 2013-10-31 20:39:09 UTC
cat > bug.d << CODE
import std.stdio;

void main()
{
    writefln("Hello %1$s!", "World");
}
CODE

dmd -run bug

----

When debugging this gdb constantly barks that it can't find the function frames.
In this specific program the format spec is incorrect.
It seems that some data/code is corrupted when linking with gold.
We should investigate whether this is an issue in dmd's codegen.
Comment 1 Atila Neves 2013-11-14 04:28:29 UTC
*** Issue 11492 has been marked as a duplicate of this issue. ***
Comment 2 Atila Neves 2013-11-14 04:31:49 UTC
I think the importance is higher than normal. It's not just not being able to debug, the produced executables can actually crash and do so if using std.concurrency. See this duplicate I filed:

https://d.puremagic.com/issues/show_bug.cgi?id=11492
Comment 3 Martin Nowak 2013-11-14 07:00:48 UTC
(In reply to comment #2)
> I think the importance is higher than normal.

I think so too, raised to critical. Seems like more people (distributions?) begin to use ld.gold. Probably due to reduced link times.
Comment 4 Martin Nowak 2013-11-14 09:30:49 UTC
cat > bug.d << CODE
enum Op { a, b, c, d, }

void bug(Op op)
{
    final switch (op)
    {
    case Op.a:
    case Op.b:
    case Op.c:
    case Op.d:
    }
}

void main()
{
    bug(Op.a);
}
CODE

There are an extra 8-bytes at the start of the switch table. Maybe an alignment issue?
Comment 6 github-bugzilla 2013-11-17 00:38:23 UTC
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/905d00af03efc9f8bbdb3d25e9776b0d0061783e
fix Issue 11406 - ld.gold breaks switch table jumps

- This is due to the fact that gold doesn't add target
  addends to relocations (only uses the 64-bit rela addend).

https://github.com/D-Programming-Language/dmd/commit/854896cab40632cd3d2cd40d6461c62c36e6a79a
Merge pull request #2768 from dawgfoto/fix11406

fix Issue 11406 - ld.gold breaks switch table jumps
Comment 7 github-bugzilla 2013-11-17 00:44:40 UTC
Commit pushed to dmd-1.x at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/774eb391bbf324a5ab064a19cc48e549719958b1
Merge pull request #2768 from dawgfoto/fix11406

fix Issue 11406 - ld.gold breaks switch table jumps