This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[ARM] fix cortex-a8-fix bug
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: binutils <binutils at sources dot redhat dot com>
- Date: Thu, 06 Aug 2009 14:03:45 +0100
- Subject: [ARM] fix cortex-a8-fix bug
I've applied this obvious patch to fix a cortex-a8-fix bug. The nature of the
erratum means that section alignments must be preserved modulo the page size,
and rather than force the section alignment to be the page size (and introduce
padding), we must ensure they don't move after we've applied the fix.
Unfortunately, we only call layout_sections_again if we find at least one stub
to insert, so when there are none to insert (on the initial pass), we leave it
to a later linker stage to do the layout. That subsequent layout can move
sections around, if ELF headers are to be placed in the first segment.
Fixed thusly, tested on arm-eabi and arm-linux-gnueabi.
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery
2009-08-06 Nathan Sidwell <nathan@codesourcery.com>
bfd/
* elf32-arm.c (elf32_arm_size_stubs): Call layout_sections_again
at least once when fixing cortex-a8.
ld/testsuite/
* ld-arm/arm-elf.exp: Add new test.
* ld-arm/cortex-a8-fix-hdr.d: New.
* ld-arm/cortex-a8-fix-hdr.s: New.
* ld-arm/cortex-a8-fix-hdr.t: New.
Index: bfd/elf32-arm.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-arm.c,v
retrieving revision 1.207
diff -c -3 -p -r1.207 elf32-arm.c
*** bfd/elf32-arm.c 5 Aug 2009 12:36:14 -0000 1.207
--- bfd/elf32-arm.c 6 Aug 2009 12:58:52 -0000
*************** elf32_arm_size_stubs (bfd *output_bfd,
*** 4246,4251 ****
--- 4246,4261 ----
group_sections (htab, stub_group_size, stubs_always_after_branch);
+ /* If we're applying the cortex A8 fix, we need to determine the
+ program header size now, because we cannot change it later --
+ that could alter section placements. Notice the A8 erratum fix
+ ends up requiring the section addresses to remain unchanged
+ modulo the page size. That's something we cannot represent
+ inside BFD, and we don't want to force the section alignment to
+ be the page size. */
+ if (htab->fix_cortex_a8)
+ (*htab->layout_sections_again) ();
+
while (1)
{
bfd *input_bfd;
Index: ld/testsuite/ld-arm/arm-elf.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-arm/arm-elf.exp,v
retrieving revision 1.60
diff -c -3 -p -r1.60 arm-elf.exp
*** ld/testsuite/ld-arm/arm-elf.exp 5 Aug 2009 12:36:14 -0000 1.60
--- ld/testsuite/ld-arm/arm-elf.exp 6 Aug 2009 12:58:53 -0000
*************** set armelftests {
*** 209,214 ****
--- 209,218 ----
"-EL -Ttext=0x00 --fix-cortex-a8 --defsym far_fn1=0x80000000 --defsym far_fn2=0x80000004 --defsym far_fn=0x7fff0000 --defsym _start=0" "-EL" {cortex-a8-far-1.s cortex-a8-far-2.s}
{{objdump -dr cortex-a8-far.d}}
"cortex-a8-far"}
+ {"Cortex-A8 erratum fix, headers"
+ "-EL --fix-cortex-a8 -T cortex-a8-fix-hdr.t" "-EL" {cortex-a8-fix-hdr.s}
+ {{objdump -dr cortex-a8-fix-hdr.d}}
+ "cortex-a8-fix-hdr"}
{"Unwinding and -gc-sections" "-gc-sections" "" {gc-unwind.s}
{{objdump -sj.data gc-unwind.d}}
"gc-unwind"}
Index: ld/testsuite/ld-arm/cortex-a8-fix-hdr.d
===================================================================
RCS file: ld/testsuite/ld-arm/cortex-a8-fix-hdr.d
diff -N ld/testsuite/ld-arm/cortex-a8-fix-hdr.d
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- ld/testsuite/ld-arm/cortex-a8-fix-hdr.d 6 Aug 2009 12:58:53 -0000
***************
*** 0 ****
--- 1,24 ----
+
+ .*: file format .*
+
+
+ Disassembly of section \.text:
+
+ 00000fe0 <_start>:
+ fe0: bf00 nop
+ fe2: bf00 nop
+ fe4: bf00 nop
+ fe6: bf00 nop
+ fe8: bf00 nop
+ fea: bf00 nop
+ fec: bf00 nop
+ fee: bf00 nop
+ ff0: bf00 nop
+ ff2: bf00 nop
+ ff4: bf00 nop
+ ff6: bf00 nop
+ ff8: bf00 nop
+ ffa: ea81 0002 eor.w r0, r1, r2
+ ffe: f000 b80f b.w 1020 <_start\+0x40>
+ #...
+ 1020: f7ff bfde b.w fe0 <_start>
Index: ld/testsuite/ld-arm/cortex-a8-fix-hdr.s
===================================================================
RCS file: ld/testsuite/ld-arm/cortex-a8-fix-hdr.s
diff -N ld/testsuite/ld-arm/cortex-a8-fix-hdr.s
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- ld/testsuite/ld-arm/cortex-a8-fix-hdr.s 6 Aug 2009 12:58:53 -0000
***************
*** 0 ****
--- 1,14 ----
+ .syntax unified
+
+ .section .text, "ax"
+
+ .align 5
+ .globl _start
+ .thumb_func
+ _start:
+ .rept 13
+ nop
+ .endr
+ eor r0, r1, r2
+ b.w _start
+
Index: ld/testsuite/ld-arm/cortex-a8-fix-hdr.t
===================================================================
RCS file: ld/testsuite/ld-arm/cortex-a8-fix-hdr.t
diff -N ld/testsuite/ld-arm/cortex-a8-fix-hdr.t
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- ld/testsuite/ld-arm/cortex-a8-fix-hdr.t 6 Aug 2009 12:58:53 -0000
***************
*** 0 ****
--- 1,10 ----
+
+
+ SECTIONS {
+ . = SIZEOF_HEADERS;
+ . += 0xf80;
+ .text : {
+ *(.text)
+ } = 0
+ /DISCARD/ : { *(*) }
+ }