http://sourceware.org/bugzilla/show_bug.cgi?id=15787
Bug ID: 15787 Summary: Better choice for B(S) value in ARM relocations Product: binutils Version: 2.24 (HEAD) Status: NEW Severity: normal Priority: P2 Component: ld Assignee: unassigned at sourceware dot org Reporter: j...@bass-software.com Created attachment 7122 --> http://sourceware.org/bugzilla/attachment.cgi?id=7122&action=edit Proposed patch for a better B(S) choice for R_ARM_{ALU|LDR\LDC|LDRS}_SB_G{0|1|2} 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. Concerning tests : we originally had 4 linker groups tests : group-relocs-alu-bad, group-relocs-ldc-bad, group-relocs-ldr-bad and group-relocs-ldrs-bad. The first two were pc-based, the last two were sb-based. I've changed the last two in pc-based as well and added 4 new sb-based tests. Tested binutils, ld and gas with target arm-unknown-eabi, no regressions. I've a copyright assignment but no write acccess. bfd John Tytgat <j...@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 <j...@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. -- You are receiving this mail because: You are on the CC list for the bug. _______________________________________________ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils