This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH, ARM]: Fix SB group relocations


ARM's IHI0044E document specifies the B(S) for the
R_ARM_{ALU|LDR|LDC|LDRS}_SB_G{0|1|2} relocations as:

B(S) is the addressing origin of the output segment defining the symbol S.
The origin is not required to be the base address of the segment. This
value must always be word-aligned.

However currently in bfd/elf32-arm.c the sb value gets calculated as:

	/* sb should be the origin of the *segment* containing the symbol.
	   It is not clear how to obtain this OS-dependent value, so we
	   make an arbitrary choice of zero.  */
	bfd_vma sb = 0;

IMHO this is wrong and this is not about the origin of the output segment
at run time but about the one which gets determined at linking time.  As
sb group relocations are static ones they are most probably the same so we
better use sym_sec->output_section->vma instead of a fixed value 0.

Please find patch attached.

Tested binutils, ld and gas with target arm-unknown-eabi, no regressions.

I've a copyright assignment but no write acccess.

bfd

John Tytgat  <john@bass-software.com>

	* elf32-arm.c (elf32_arm_final_link_relocate): Use origin of output
	segment containing the relocating symbol instead of assuming 0 for
	sb group relocations.

ld/testsuite

John Tytgat  <john@bass-software.com>

	* ld-arm/group-relocs.s: Add comments.  Move symbols used for sb
	group relocations into .data section.  Drop section zero.  Use pc/r0
	as base register when pc/sb group relocations are used.
	* ld-arm/group-relocs.d: Adjust expected result.
	* ld-arm/group-relocs-ldr-bad.s: Use pc_g0/pc_g1 relocs instead of
	sb_g0/sb_g1.
	* ld-arm/group-relocs-ldrs-bad.s: Likewise.
	* ld-arm/group-relocs-ldr-bad.d: Adjust expected result.
	* ld-arm/group-relocs-ldrs-bad.d: Likewise.
	* ld-arm/group-relocs-alu-bad-2.d: New test for sb group relocation.
	* ld-arm/group-relocs-ldr-bad-2.d: Likewise.
	* ld-arm/group-relocs-ldrs-bad-2.d: Likewise.
	* ld-arm/group-relocs-ldc-bad-2.d: Likewise.
	* ld-arm/group-relocs-alu-bad-2.s: New test source.
	* ld-arm/group-relocs-ldr-bad-2.s: Likewise.
	* ld-arm/group-relocs-ldrs-bad-2.s: Likewise.
	* ld-arm/group-relocs-ldc-bad-2.s: Likewise.
	* ld-arm/arm-elf.exp: For group-relocs, drop section zero start
	definition.  Run the new tests.

John.
-- 
John Tytgat                                                             BASS
John@bass-software.com

Attachment: arm_sb_g_reloc.patch
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]