Patch to allow ARM dynamic linker to fix up PC24 relocs...
Scott Bambrough
scottb@netwinder.org
Tue Dec 7 11:50:00 GMT 1999
Hi guys,
The attached patch allows the ARM dynamic linker to fix up PC24 relocs
in the code segment. A bit of background is attached.
The PC24 reloc is generated for ARM branch and branch and link
instructions (b,bl). The least significant 24 bits are used to for a 26
bit offset (the offset is modulo 4). The address calculation performed
by the CPU is as follows:
PC = PC + (SignExtend(<24_bit_signed_offset>) << 2;
If the calculated 26 bit offset is out of range, the dynamic linker
displays an error message like the following:
foo_dynamic: error in loading shared libraries: ./foo.so: R_ARM_PC24
relocation out of range
1999-12-07 Scott Bambrough <scottb@netwinder.org>
* sysdeps/arm/dl-machine.h (elf_machine_rel): Fixup R_ARM_PC24
relocs if possible.
--
Scott Bambrough - Software Engineer
REBEL.COM http://www.rebel.com
NetWinder http://www.netwinder.org
--- dl-machine.h.orig Fri Nov 26 08:56:05 1999
+++ dl-machine.h Tue Dec 7 14:04:13 1999
@@ -446,6 +446,23 @@ elf_machine_rel (struct link_map *map, c
*reloc_addr += value;
break;
}
+ case R_ARM_PC24:
+ {
+ signed int addend;
+
+ addend = *reloc_addr & 0x00ffffff;
+ if (addend & 0x00800000) addend |= 0xff000000;
+
+ value = value - (unsigned int)reloc_addr + (addend << 2);
+ if (value & 0xfc000003)
+ _dl_signal_error (0, map->l_name,
+ "R_ARM_PC24 relocation out of range");
+
+ value = value >> 2;
+ value = (*reloc_addr & 0xff000000) | (value & 0x00ffffff);
+ *reloc_addr = value;
+ }
+ break;
default:
assert (! "unexpected dynamic reloc type");
break;
More information about the Libc-hacker
mailing list