Bug 13362 - internal error in value_from_output_section, at ../../gold/reloc.cc:1549 on armel
Summary: internal error in value_from_output_section, at ../../gold/reloc.cc:1549 on a...
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: gold (show other bugs)
Version: 2.24
: P2 normal
Target Milestone: ---
Assignee: Ian Lance Taylor
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-31 03:06 UTC by Jonathan Nieder
Modified: 2011-12-20 08:44 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
kernel module generated with systemtap 1.6-1 (27.35 KB, application/x-xz)
2011-10-31 03:06 UTC, Jonathan Nieder
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Nieder 2011-10-31 03:06:02 UTC
Created attachment 6042 [details]
kernel module generated with systemtap 1.6-1

Hi,

Timo Lindfors found that running "ld.gold -r -o typequery_kmod_8.ko typequery_kmod_8.o" with this object file on his openmoko and on his marvell development board (which are ARMv4 and v5, respectively) produces

 ld.gold: internal error in value_from_output_section, at ../../gold/reloc.cc:1549

Just like PR12771, it's reproducible with real hardware but not on qemu
(since qemu doesn't emulate misaligned accesses with a trap or rotation).
Timo checked that the testcase from PR12771 still isn't causing trouble,
so this is a distinct bug.

Tests so far have been with version 2.21.90.20111025-1 from Debian sid.

After running "echo 5 >/proc/cpu/alignment", it dies with SIGBUS instead.
So we can get a backtrace:

 #0  rel<32> at gold/i386.cc:3632
 #1  rel32 at gold/reloc.h:559
 #2  gold::relocate_for_relocatable<32, false, 9> at gold/target-reloc.h:784
 #3  gold::Sized_relobj_file<32, false>::do_relocate_sections at gold/reloc.cc:1027
 #4  (anonymous namespace)::Arm_relobj<false>::do_relocate_sections at gold/arm.cc:6452
 #5  relocate_sections at gold/object.h:2337
 #6  gold::Sized_relobj_file<32, false>::do_relocate at gold/reloc.cc:670
 #7  relocate at gold/object.h:1074
 #8  gold::Relocate_task::run at gold/reloc.cc:239
 #9  gold::Workqueue::find_and_run_task at gold/workqueue.cc:319

Details, including a fuller backtrace, are at http://bugs.debian.org/647049
Comment 1 Ian Lance Taylor 2011-10-31 04:39:31 UTC
I believe this is already fixed on mainline and in the upcoming 2.22 release.

*** This bug has been marked as a duplicate of bug 12771 ***
Comment 2 Jonathan Nieder 2011-10-31 06:30:55 UTC
ian at airs dot com wrote:

> I believe this is already fixed on mainline and in the upcoming 2.22 release.

To be clear, as mentioned above, Timo used the testcase from PR12771
to confirm that the fix to PR12771 is already applied.  Timo was
testing using a recent snapshot of binutils-2_22-branch.

This might or might not be fixed on mainline (I don't have the
hardware to check), but I don't see how it can be a duplicate of
PR12771.
Comment 3 Jonathan Nieder 2011-10-31 19:51:09 UTC
Hi again,

Quick update now that I have (remote) access to some hardware to test on (thanks, Timo!):

Testing yesterday's HEAD (commit 5625fcaf, daily update, 2011-10-30), I get the following result:

 $ make check
[...]
 (cd gcctestdir2 && ln -s ../ld1 ld)
 g++ -W -Wall    -Werror -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -frandom-seed=ld2 -g -O2 -Bgcctestdir2/  -o ld2 main.o i386.o x86_64.o sparc.o powerpc.o arm.o arm-reloc-property.o libgold.a ../libiberty/libiberty.a     -lz 
 gcctestdir1/ld -o libgold-1-r.o -r --whole-archive libgold.a
 make[4]: *** [libgold-1-r.o] Bus error
 make[4]: *** Deleting file `libgold-1-r.o'
 make[4]: Leaving directory `/home/jrn/src/binutils/gold'
 make[3]: *** [check-am] Error 2
 make[3]: Leaving directory `/home/jrn/src/binutils/gold'
 make[2]: *** [check-recursive] Error 1
 make[2]: Leaving directory `/home/jrn/src/binutils/gold'
 make[1]: *** [check-gold] Error 2
 make[1]: Leaving directory `/home/jrn/src/binutils'
 make: *** [do-check] Error 2

So I'm taking the liberty of reopening the bug. If I am missing something, please feel free to let me know.

Thanks for gold, of course.
Comment 4 Doug Kwan 2011-10-31 20:20:43 UTC
I am looking at it.
Comment 5 Doug Kwan 2011-11-01 21:24:49 UTC
(In reply to comment #4)
> I am looking at it.

This is a different problem than bug 12771,  which happened in the ARM backend.  The problem here is that relocate_for_relocatable does does not handle unaligned accesses properly.
Comment 6 cvs-commit@gcc.gnu.org 2011-11-10 00:41:56 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	dougkwan@sourceware.org	2011-11-10 00:41:53

Modified files:
	gold           : ChangeLog arm.cc reloc.h target-reloc.h 
	gold/testsuite : Makefile.am Makefile.in arm_unaligned_reloc.sh 

Log message:
	2011-11-09  Doug Kwan  <dougkwan@google.com>
	
	PR gold/13362
	* arm.cc (Arm_scan_relocatable_relocs::Default_scan_relocatable_relocs):
	Use unaligned 4-byte relocs for static 32-bit data as required by EABI.
	* reloc.h (Relocatable_relocs::Reloc_strategy): New enum
	RELOC_ADJUST_FOR_SECTION_4_UNALIGNED.
	(Relocate_functions::rel_unaligned): New.
	(Relocate_functions::rel32_unaligned): New.
	* target-reloc.h (relocate_for_relocatable): Add code to handle
	RELOC_ADJUST_FOR_SECTION_4_UNALIGNED.
	* testsuite/Makefile.am (arm_unaligned_reloc_r.stdout,
	arm_unaligned_reloc_r): New targets.
	* testsuite/Makefile.in: Regenerate.
	* arm_unaligned_reloc.sh: Check unaligned relocs in relocatable
	linking.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/ChangeLog.diff?cvsroot=src&r1=1.851&r2=1.852
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/arm.cc.diff?cvsroot=src&r1=1.140&r2=1.141
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/reloc.h.diff?cvsroot=src&r1=1.31&r2=1.32
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/target-reloc.h.diff?cvsroot=src&r1=1.50&r2=1.51
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/testsuite/Makefile.am.diff?cvsroot=src&r1=1.185&r2=1.186
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/testsuite/Makefile.in.diff?cvsroot=src&r1=1.195&r2=1.196
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/testsuite/arm_unaligned_reloc.sh.diff?cvsroot=src&r1=1.1&r2=1.2
Comment 7 Jonathan Nieder 2011-11-10 03:40:36 UTC
Hi Doug,

cvs-commit at gcc dot gnu.org wrote:

> Modified files:
>     gold           : ChangeLog arm.cc reloc.h target-reloc.h 
>     gold/testsuite : Makefile.am Makefile.in arm_unaligned_reloc.sh 

FWIW, I tried applying this patch on top of e0e67cec (daily update,
2011-11-09).  The result:

| $ make check
[...]
| g++ -W -Wall    -Werror -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fmerge-constants -g -O2 -Bgcctestdir/  -o tls_test tls_test.o tls_test_file2.o tls_test_main.o tls_test_c.o -lpthread -lz 
| collect2: ld terminated with signal 7 [Bus error]
| make[3]: *** [tls_test] Error 1
| make[3]: Leaving directory `/home/jrn/src/binutils/gold/testsuite'

which looks like progress.  This is on a Marvell DB-78x00-BP
Development Board (v5l).

Thanks and hope that helps,
Jonathan
Comment 8 Jonathan Nieder 2011-11-10 04:09:30 UTC
Jonathan Nieder wrote:

> | $ make check
> [...]
> | g++ -W -Wall    -Werror -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fmerge-constants -g -O2 -Bgcctestdir/  -o tls_test tls_test.o tls_test_file2.o tls_test_main.o tls_test_c.o -lpthread -lz 
> | collect2: ld terminated with signal 7 [Bus error]

More precisely:

| Program received signal SIGBUS, Bus error.
| 0x000841ac in rel<32> (value=32, view=0x2eb938 "0.,") at reloc.h:333
| 333         elfcpp::Swap<valsize, big_endian>::writeval(wv, x + value);

Backtrace:

  #0  rel<32> at reloc.h:333
  #1  rel32 at reloc.h:569
  #2  relocate_tls at arm.cc:9376
  #3  (anonymous namespace)::Target_arm<false>::Relocate::relocate at
       arm.cc:9256
  #4  relocate_section<32, false, {anonymous}::Target_arm<false>, 9, {anonymous}::Target_arm<false>::Relocate>
       at target-reloc.h:385
  #5  (anonymous namespace)::Target_arm<false>::relocate_section at arm.cc:9478
  #6  gold::Sized_relobj_file<32, false>::do_relocate_sections at reloc.cc:1013
  #7  (anonymous namespace)::Arm_relobj<false>::do_relocate_sections
       at arm.cc:6471
  #8  relocate_sections at object.h:2337
  #9  gold::Sized_relobj_file<32, false>::do_relocate at reloc.cc:670
 #10  relocate at object.h:1074
 #11  gold::Relocate_task::run at reloc.cc:239
 #12  gold::Workqueue::find_and_run_task at workqueue.cc:319

Worth a separate report?
Comment 9 Doug Kwan 2011-11-10 05:26:10 UTC
I think there are still problems.  I had problem reproducing this on a
Pandaboard but I will try adding an assert in rel to see if I can
catch all problems.

-Doug

On Wed, Nov 9, 2011 at 8:09 PM, jrnieder at gmail dot com
<sourceware-bugzilla@sourceware.org> wrote:
> http://sourceware.org/bugzilla/show_bug.cgi?id=13362
>
> --- Comment #8 from Jonathan Nieder <jrnieder at gmail dot com> 2011-11-10 04:09:30 UTC ---
> Jonathan Nieder wrote:
>
>> | $ make check
>> [...]
>> | g++ -W -Wall    -Werror -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fmerge-constants -g -O2 -Bgcctestdir/  -o tls_test tls_test.o tls_test_file2.o tls_test_main.o tls_test_c.o -lpthread -lz
>> | collect2: ld terminated with signal 7 [Bus error]
>
> More precisely:
>
> | Program received signal SIGBUS, Bus error.
> | 0x000841ac in rel<32> (value=32, view=0x2eb938 "0.,") at reloc.h:333
> | 333         elfcpp::Swap<valsize, big_endian>::writeval(wv, x + value);
>
> Backtrace:
>
>  #0  rel<32> at reloc.h:333
>  #1  rel32 at reloc.h:569
>  #2  relocate_tls at arm.cc:9376
>  #3  (anonymous namespace)::Target_arm<false>::Relocate::relocate at
>       arm.cc:9256
>  #4  relocate_section<32, false, {anonymous}::Target_arm<false>, 9,
> {anonymous}::Target_arm<false>::Relocate>
>       at target-reloc.h:385
>  #5  (anonymous namespace)::Target_arm<false>::relocate_section at arm.cc:9478
>  #6  gold::Sized_relobj_file<32, false>::do_relocate_sections at reloc.cc:1013
>  #7  (anonymous namespace)::Arm_relobj<false>::do_relocate_sections
>       at arm.cc:6471
>  #8  relocate_sections at object.h:2337
>  #9  gold::Sized_relobj_file<32, false>::do_relocate at reloc.cc:670
>  #10  relocate at object.h:1074
>  #11  gold::Relocate_task::run at reloc.cc:239
>  #12  gold::Workqueue::find_and_run_task at workqueue.cc:319
>
> Worth a separate report?
>
> --
> Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
> ------- You are receiving this mail because: -------
> You are on the CC list for the bug.
>
Comment 10 cvs-commit@gcc.gnu.org 2011-11-10 20:53:43 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	dougkwan@sourceware.org	2011-11-10 20:53:36

Modified files:
	gold           : ChangeLog arm.cc reloc.h 

Log message:
	2011-11-10  Doug Kwan  <dougkwan@google.com>
	
	PR gold/13362
	* arm.cc (Target_arm::Relocate::relocate_tls): Do unaligned accesses
	when processing data relocs.
	* reloc.h (Relocate_functions::rel_unaligned): New method.
	(Relocate_functions::pcrel_unaligned): Ditto.
	(Relocate_functions::rel32_unaligned): Ditto.
	(Relocate_functions::pcrel32_unaligned): Ditto.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/ChangeLog.diff?cvsroot=src&r1=1.852&r2=1.853
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/arm.cc.diff?cvsroot=src&r1=1.141&r2=1.142
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/reloc.h.diff?cvsroot=src&r1=1.32&r2=1.33
Comment 11 cvs-commit@gcc.gnu.org 2011-11-21 09:32:21 UTC
CVSROOT:	/cvs/src
Module name:	src
Branch: 	binutils-2_22-branch
Changes by:	gingold@sourceware.org	2011-11-21 09:32:17

Modified files:
	gold           : arm.cc reloc.h target-reloc.h 
	gold/testsuite : Makefile.am Makefile.in arm_unaligned_reloc.sh 

Log message:
	Merge of
	CVSROOT:	/cvs/src
	Module name:	src
	Changes by:	dougkwan@sourceware.org	2011-11-10 00:41:53
	
	Modified files:
	gold           : ChangeLog arm.cc reloc.h target-reloc.h
	gold/testsuite : Makefile.am Makefile.in arm_unaligned_reloc.sh
	
	Log message:
	2011-11-09  Doug Kwan  <dougkwan@google.com>
	
	PR gold/13362
	* arm.cc (Arm_scan_relocatable_relocs::Default_scan_relocatable_relocs):
	Use unaligned 4-byte relocs for static 32-bit data as required by EABI.
	* reloc.h (Relocatable_relocs::Reloc_strategy): New enum
	RELOC_ADJUST_FOR_SECTION_4_UNALIGNED.
	(Relocate_functions::rel_unaligned): New.
	(Relocate_functions::rel32_unaligned): New.
	* target-reloc.h (relocate_for_relocatable): Add code to handle
	RELOC_ADJUST_FOR_SECTION_4_UNALIGNED.
	* testsuite/Makefile.am (arm_unaligned_reloc_r.stdout,
	arm_unaligned_reloc_r): New targets.
	* testsuite/Makefile.in: Regenerate.
	* arm_unaligned_reloc.sh: Check unaligned relocs in relocatable
	linking.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/arm.cc.diff?cvsroot=src&only_with_tag=binutils-2_22-branch&r1=1.138.2.1&r2=1.138.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/reloc.h.diff?cvsroot=src&only_with_tag=binutils-2_22-branch&r1=1.31&r2=1.31.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/target-reloc.h.diff?cvsroot=src&only_with_tag=binutils-2_22-branch&r1=1.50&r2=1.50.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/testsuite/Makefile.am.diff?cvsroot=src&only_with_tag=binutils-2_22-branch&r1=1.182.2.1&r2=1.182.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/testsuite/Makefile.in.diff?cvsroot=src&only_with_tag=binutils-2_22-branch&r1=1.191.2.1&r2=1.191.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/testsuite/arm_unaligned_reloc.sh.diff?cvsroot=src&only_with_tag=binutils-2_22-branch&r1=1.1&r2=1.1.2.1
Comment 12 cvs-commit@gcc.gnu.org 2011-11-21 09:40:01 UTC
CVSROOT:	/cvs/src
Module name:	src
Branch: 	binutils-2_22-branch
Changes by:	gingold@sourceware.org	2011-11-21 09:39:58

Modified files:
	gold           : ChangeLog arm.cc reloc.h 

Log message:
	Merge of:
	CVSROOT:	/cvs/src
	Module name:	src
	Changes by:	dougkwan@sourceware.org	2011-11-10 20:53:36
	
	Modified files:
	gold           : ChangeLog arm.cc reloc.h
	
	Log message:
	2011-11-10  Doug Kwan  <dougkwan@google.com>
	
	PR gold/13362
	* arm.cc (Target_arm::Relocate::relocate_tls): Do unaligned accesses
	when processing data relocs.
	* reloc.h (Relocate_functions::rel_unaligned): New method.
	(Relocate_functions::pcrel_unaligned): Ditto.
	(Relocate_functions::rel32_unaligned): Ditto.
	(Relocate_functions::pcrel32_unaligned): Ditto.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/ChangeLog.diff?cvsroot=src&only_with_tag=binutils-2_22-branch&r1=1.824.2.4&r2=1.824.2.5
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/arm.cc.diff?cvsroot=src&only_with_tag=binutils-2_22-branch&r1=1.138.2.2&r2=1.138.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/reloc.h.diff?cvsroot=src&only_with_tag=binutils-2_22-branch&r1=1.31.2.1&r2=1.31.2.2
Comment 13 Jonathan Nieder 2011-12-20 08:44:32 UTC
Seems to be fixed, based on a test with upstream binutils 2.22.
Thanks for making it happen.