Bug 14814 – ld: GOT load reloc does not point to a movq instruction

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Mac OS X
Creation time
2015-07-20T07:39:39Z
Last change time
2020-07-16T09:56:08Z
Assigned to
No Owner
Creator
Timothee Cour
See also
https://issues.dlang.org/show_bug.cgi?id=21047

Comments

Comment #0 by timothee.cour2 — 2015-07-20T07:39:39Z
Reduced use case: https://github.com/timotheecour/dsnippet/tree/master/bug_ld_GOT_reloc dmd -of/tmp/fun3.o -c fun3.d && dmd -of/tmp/z01 /tmp/fun3.o fun2.d ld: GOT load reloc does not point to a movq instruction in '_D4fun34fun4FZv' from /tmp/fun3.o for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) fun2: import fun3; void main(){ fun4; } fun3: void fun0() { } alias Fun = void function(); //same with delegate() void fun4() { Fun[TypeInfo] funs; funs[typeid(int)] = &fun0; //same with s/&fun0/(){}/ } NOTE: not sure whether b/7354 is related; it's very old but this one is a regression.
Comment #1 by code — 2015-07-21T07:48:15Z
Regression in which dmd version? Can you please bisect dmd using Digger (https://github.com/CyberShadow/Digger)?
Comment #2 by timothee.cour2 — 2015-07-21T08:09:51Z
(In reply to Martin Nowak from comment #1) > Regression in which dmd version? > Can you please bisect dmd using Digger > (https://github.com/CyberShadow/Digger)? I had written it in that link https://github.com/timotheecour/dsnippet/tree/master/bug_ld_GOT_reloc : ` dmd --version DMD64 D Compiler v2.068-devel-80a326e NOTE: works fine with dmd v2.067.1 `
Comment #3 by timothee.cour2 — 2015-07-21T09:36:06Z
(In reply to Timothee Cour from comment #2) > (In reply to Martin Nowak from comment #1) > > Regression in which dmd version? > > Can you please bisect dmd using Digger > > (https://github.com/CyberShadow/Digger)? > > I had written it in that link > https://github.com/timotheecour/dsnippet/tree/master/bug_ld_GOT_reloc : > ` > dmd --version > DMD64 D Compiler v2.068-devel-80a326e > NOTE: works fine with dmd v2.067.1 > ` ok here's a more fine grained version showing https://github.com/D-Programming-Language/dmd/pull/4654 is the culprit: digger: 2c5809577aafd8c6199dc04ca4ea874c4bafae9b is the first bad commit commit 2c5809577aafd8c6199dc04ca4ea874c4bafae9b Author: Hara Kenji <[email protected]> Date: Mon May 18 23:37:54 2015 +0900 dmd: Merge pull request #4654 from yebblies/typeid https://github.com/D-Programming-Language/dmd/pull/4654 Resolve TypeInfo variables after semantic diff --git a/dmd b/dmd index a7d1edb..7fa9cd9 160000 --- a/dmd +++ b/dmd @@ -1 +1 @@ -Subproject commit a7d1edb3c17282994c53fdc797dc3d15f3919d68 +Subproject commit 7fa9cd9de5d24bede6cb5b4f5d4840a2b5140b7c digger: Bisection completed successfully. Thanks for suggesting using Digger!
Comment #4 by k.hara.pg — 2015-07-21T13:37:48Z
(In reply to Timothee Cour from comment #3) > ok here's a more fine grained version showing > https://github.com/D-Programming-Language/dmd/pull/4654 is the culprit: I don't have Mac OS X environment, so I cannot directly test the reduced case. But I found a difference in the glue-layer output introduced by the PR. (In reply to Timothee Cour from comment #0) > fun3: > void fun0() > { > } > > alias Fun = void function(); //same with delegate() > > void fun4() > { > Fun[TypeInfo] funs; > funs[typeid(int)] = &fun0; //same with s/&fun0/(){}/ > } If you replace the `typeid(int)` with `null`, will the failure disappear? If so, may following patch fix fix the issue? --- src/e2ir.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/e2ir.c b/src/e2ir.c index 863bd14..88d2a63 100644 --- a/src/e2ir.c +++ b/src/e2ir.c @@ -1175,6 +1175,7 @@ elem *toElem(Expression *e, IRState *irs) if (Type *t = isType(e->obj)) { result = getTypeInfo(t, irs); + result = el_bin(OPadd, result->Ety, result, el_long(TYsize_t, t->vtinfo->offset)); return; } if (Expression *ex = isExpression(e->obj)) --
Comment #5 by timothee.cour2 — 2015-07-22T04:01:34Z
>> If you replace the `typeid(int)` with `null`, will the failure disappear? yes >> If so, may following patch fix fix the issue? it does. Here's the corresponding pull request: https://github.com/D-Programming-Language/dmd/pull/4827
Comment #6 by k.hara.pg — 2015-07-22T13:12:42Z
(In reply to Timothee Cour from comment #5) > >> If you replace the `typeid(int)` with `null`, will the failure disappear? > > yes > > >> If so, may following patch fix fix the issue? > > it does. Thanks for the test. I also confirmed the issue on auto-tester with a test case, then applied my patch. https://github.com/D-Programming-Language/dmd/pull/4828
Comment #7 by k.hara.pg — 2015-07-25T00:39:08Z
(In reply to Kenji Hara from comment #6) > https://github.com/D-Programming-Language/dmd/pull/4828 New PR based on the 'stable' branch: https://github.com/D-Programming-Language/dmd/pull/4829
Comment #8 by github-bugzilla — 2015-07-25T00:40:27Z
Commits pushed to stable at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/afc3ace1fadbe47fb7bacc4ba93f3c3582f1c475 fix Issue 14814 - ld: GOT load reloc does not point to a movq instruction https://github.com/D-Programming-Language/dmd/commit/3a8dc471abbcd6952519e6ddf9f496ba3147c3f5 Merge pull request #4829 from 9rnsr/fix14814 [REG2.068a] Issue 14814 - ld: GOT load reloc does not point to a movq instruction
Comment #9 by k.hara.pg — 2015-07-25T00:43:00Z
*** Issue 14812 has been marked as a duplicate of this issue. ***
Comment #10 by github-bugzilla — 2015-07-30T12:05:44Z