Bug 12826 - [PATCH] Gold not knowing ARM7EM architecture
Summary: [PATCH] Gold not knowing ARM7EM architecture
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: gold (show other bugs)
Version: 2.21
: P2 normal
Target Milestone: ---
Assignee: Doug Kwan
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-31 12:06 UTC by Asier Llano
Modified: 2011-06-01 20:03 UTC (History)
2 users (show)

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


Attachments
Patch with the proposed change (638 bytes, patch)
2011-05-31 12:06 UTC, Asier Llano
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Asier Llano 2011-05-31 12:06:57 UTC
Created attachment 5760 [details]
Patch with the proposed change

When compiling code with gcc-4.6.0 for cpu "cortex-m4" it generates code for ARM7EM. The gold 2.21 linker tells: "unknown CPU architecture".

The error is in line 10006 of gold/arm.cc:
 if (oldtag >= elfcpp::MAX_TAG_CPU_ARCH || newtag >= elfcpp::MAX_TAG_CPU_ARCH)

This detects an error in the architecture, but if the oldtag or newtag is just
the same as elfcpp::MAX_TAG_CPU_ARCH, it detects it incorrectly as unknown CPU. Line 242 of elfcpp/arm.h:
  MAX_TAG_CPU_ARCH = TAG_CPU_ARCH_V7E_M

So it is as simple to fix as changing previous line by:
 if (oldtag > elfcpp::MAX_TAG_CPU_ARCH || newtag > elfcpp::MAX_TAG_CPU_ARCH)

So the value TAG_CPU_ARCH_V7E_M is not detected as an unknown CPU.

Included patch for easy applying.
Comment 1 Sourceware Commits 2011-06-01 19:59:45 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	dougkwan@sourceware.org	2011-06-01 19:59:42

Modified files:
	gold           : ChangeLog arm.cc 
	gold/testsuite : Makefile.am Makefile.in 
Added files:
	gold/testsuite : pr12826.sh pr12826_1.s pr12826_2.s 

Log message:
	2011-05-31  Doug Kwan  <dougkwan@google.com>
	Asier Llano
	
	PR gold/12826
	* arm.cc (Target_arm::tag_cpu_arch_combine): Fix handling of
	arch value that equals to elfcpp::MAX_TAG_CPU_ARCH.
	* testsuite/Makefile.am: (MOSTLYCLEANFILES): Clean up.  Remove
	redundant arm_exidx_test.so.
	* testsuite/Makefile.in: Regenerate.
	(check_SCRIPTS): Add pr12826.sh
	(check_DATA): Add pr12826.stdout
	(pr12826.stdout, pr12826.so, pr12826_1.o, pr12826_2.o): New rules.
	* testsuite/pr12826.sh: New file.
	* testsuite/pr12826_1.s: Ditto.
	* testsuite/pr12826_1.s: Ditto.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/ChangeLog.diff?cvsroot=src&r1=1.742&r2=1.743
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/arm.cc.diff?cvsroot=src&r1=1.132&r2=1.133
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/testsuite/pr12826.sh.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/testsuite/pr12826_1.s.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/testsuite/pr12826_2.s.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/testsuite/Makefile.am.diff?cvsroot=src&r1=1.161&r2=1.162
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/testsuite/Makefile.in.diff?cvsroot=src&r1=1.170&r2=1.171
Comment 2 Doug Kwan 2011-06-01 20:03:03 UTC
This is fixed in trunk.