https://sourceware.org/bugzilla/show_bug.cgi?id=25034
Bug ID: 25034 Summary: gold creates incorrect executable with large arrays Product: binutils Version: 2.32 Status: UNCONFIRMED Severity: normal Priority: P2 Component: gold Assignee: ccoutant at gmail dot com Reporter: greened at obbligato dot org CC: ian at airs dot com Target Milestone: --- $ cat big.c #include <stdio.h> struct { double a[512][512][512]; double b[512][512][512]; double c[512][512][512]; } bigarrays; int x; int main(void) { printf("&a: 0x%016x\n", bigarrays.a); printf("&b: 0x%016x\n", bigarrays.b); printf("&c: 0x%016x\n", bigarrays.c); printf("&x: 0x%016x\n", &x); x = 20; int i = 0; int j = 0; int k = 0; for (k = 0; k < 512; ++k) { for (j = 0; j < 512; ++j) { for (i = 0; i < 512; ++i) { bigarrays.a[k][j][i] = 0.0; bigarrays.b[k][j][i] = 0.0; bigarrays.c[k][j][i] = 0.0; } } } printf("x: %d\n", x); return 0; } $ gcc -fPIC big.c -Wl,--no-relax -o big.bfd $ ./big.bfd &a: 0x0000000000404080 &b: 0x0000000040404080 &c: 0x0000000080404080 &x: 0x0000000000404060 x: 20 $ gcc -fuse-ld=gold -fPIC big.c -o big.gold $ ./big.gold &a: 0x0000000000402060 &b: 0x0000000040402060 &c: 0x0000000080402060 &x: 0x00000000c0402060 Segmentation fault $ ld --version GNU ld (GNU Binutils) 2.32 Copyright (C) 2019 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) a later version. This program has absolutely no warranty. $ ld.gold --version GNU gold (GNU Binutils 2.32) 1.16 Copyright (C) 2019 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) a later version. This program has absolutely no warranty. gdb shows the fault here: 0x0000000000400610 <+126>: lea -0x3fffe5b7(%rip),%rax # 0xffffffffc0402060 => 0x0000000000400617 <+133>: movl $0x14,(%rax) That offset looks like a relocation overflow. Is gold trying to relax the reference and doing it incorrectly? `--no-relax` doesn't help. The code looks the same with and without the option. -- You are receiving this mail because: You are on the CC list for the bug. _______________________________________________ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils