[PATCH] Linker fix for data-only sections

Daniel Gutson dgutson@codesourcery.com
Tue Feb 2 17:36:00 GMT 2010


The attached patch fixes a bug that caused the linker to incorrectly 
mark parts of the output as containing code, rather than data,
when linking data-only sections not explicitly tagged as such.
The bug resulted in incorrect disassembly.

Technical details:
The bug occurred when a data-only section (without a $d mapping symbol,
which is permitted) was inserted after a section containing mapping
symbols (where the last one wasn't a $d), inside the same output
section. So, the data-only 'inherited' the effect of the last mapping
symbol since it didn't provide one.

The attached patch attempts to fix this issue by always adding a $d at
the beginning of data sections that don't have a mapping symbol. This 
may result in (harmless) redundancy of mapping symbols.
I added this fix in the elf_backend_output_arch_local_syms hook, since 
it looks for this purpose:
[elflink.c, calling the hook:]
   /* If backend needs to output some local symbols not present in the hash
      table, do it now.  */

I tested this fix by running the following test suites:
     * binutils
     * gas
     * ld (with a new test case)
     * gcc
     * g++
     * libstdc++

Please let me know if OK to commit.

ChangeLog:

2010-02-02  Daniel Gutson  <dgutson@codesourcery.com>

	bfd/
	* elf32-arm.c (elf32_arm_output_arch_local_syms): add
	missing mapping symbol to data only sections.

	ld/testsuite/
	* ld-arm/arm-elf.exp (armelftests): New test case added.
	* ld-arm/data-only-map.s: New file.
	* ld-arm/data-only-map.d: New file.

Thanks!
	Daniel.

-- 
Daniel Gutson
CodeSourcery
www.codesourcery.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: data-only-map.patch
Type: text/x-diff
Size: 4464 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20100202/58255fb8/attachment.bin>


More information about the Binutils mailing list