Bug 12815 - Segmentation fault when using a global variable, a special linker script and emulation elf64mmix
Summary: Segmentation fault when using a global variable, a special linker script and ...
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.21
: P2 normal
Target Milestone: ---
Assignee: Hans-Peter Nilsson
Depends on:
Reported: 2011-05-27 08:44 UTC by Nils Asmussen
Modified: 2011-07-25 01:23 UTC (History)
2 users (show)

See Also:
Host: Ubuntu on x86_64
Target: MMIX
Build: gcc-4.6.0 with binutils-2.21
Last reconfirmed:

Object file, that causes the error (243 bytes, application/octet-stream)
2011-05-27 15:42 UTC, Nils Asmussen

Note You need to log in before you can comment on or make changes to this bug.
Description Nils Asmussen 2011-05-27 08:44:38 UTC
I've build a cross-compiler with gcc-4.6.0 and binutils-2.21 for MMIX. There seems to be a problem with the emulation elf64mmix.

To reproduce the problem, use the following c-file:
static unsigned int foo = 2;
int main(void) {
	return 0;
And the following linker-script:
	. = 0x8000000000100000;
	.text : AT(ADDR(.text) - 0x8000000000100000)

Compiling the c-file and linking it via:
$ mmix-elf-escape-gcc -o test.o -c test.c
$ mmix-elf-escape-ld -m elf64mmix -o test test.o -T ld.conf -nostdlib

Segmentation fault
Comment 1 Nils Asmussen 2011-05-27 09:03:03 UTC
After playing around a bit with the linker-script, I've found out, that the only problem seems to be that I would like to have OUTPUT_FORMAT "binary" instead of "elf64-mmix". As soon as I use "elf64-mmix", it works.
Comment 2 Hans-Peter Nilsson 2011-05-27 14:40:03 UTC
Can you please attach test.o, the object file?  Thanks.

While it's definitely a bug that the linker segfaults, generating a "binary" file is generally better done using objcopy.
Comment 3 Nils Asmussen 2011-05-27 15:42:28 UTC
Created attachment 5758 [details]
Object file, that causes the error
Comment 4 Hans-Peter Nilsson 2011-05-28 23:43:42 UTC
Ok, repeated.
Comment 5 cvs-commit@gcc.gnu.org 2011-07-25 01:14:23 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	hp@sourceware.org	2011-07-25 01:14:20

Modified files:
	bfd            : ChangeLog elf64-mmix.c 

Log message:
	PR ld/12815
	* elf64-mmix.c (struct _mmix_elf_section_data): New members
	has_warned_bpo and has_warned_pushj.
	(mmix_final_link_relocate): Remove PARAMS and PTR macros,
	converting to ISO C.  Add new parameter error_message.  All
	callers changed.
	(mmix_elf_perform_relocation): Ditto.
	Handle the case where mmix_elf_check_common_relocs has not been
	called, missing preparations for relocs of the respective type.

Comment 7 Hans-Peter Nilsson 2011-07-25 01:23:47 UTC
Will instead error gracefully starting with binutils-2.22.
See <http://sourceware.org/ml/binutils/2011-07/msg00199.html>.
If the error message isn't helpful enough, please suggest improvements here or on the list.  Thanks for the report.