FreeCalypso > hg > freecalypso-tools
comparison toolchain/binutils-patches/elf32-arm.patch @ 0:e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 11 Jun 2016 00:13:35 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e7502631a0f9 |
---|---|
1 # The present patch to the ARM ELF linking code in binutils (made against | |
2 # binutils-2.21.1a) is a hack that affects the generation of Thumb->ARM | |
3 # call veneers. The binutils linker can make these veneers in two forms: | |
4 # | |
5 # "Short" "Long" | |
6 # (16-bit) bx pc (16-bit) bx pc | |
7 # (16-bit) nop (16-bit) nop | |
8 # (32-bit) b dest (32-bit) ldr pc, [pc, #-4] | |
9 # (32-bit) .long target | |
10 # | |
11 # For code that's going to run on the Calypso ARM7 processor, the | |
12 # "short" form is the one we want: because of the way the address space | |
13 # is laid out, the range of an ARM branch instruction will always be | |
14 # sufficient for us, whereas the long version is more costly in terms | |
15 # of the number of cycles required, especially when executing from | |
16 # external memory. | |
17 # | |
18 # Unfortunately, the code which decides between these two forms | |
19 # (located in the arm_type_of_stub() function in bfd/elf32-arm.c) | |
20 # is broken. The original code (which you can see below in the | |
21 # "before" part of the patch hunk) exhibits two problems: | |
22 # | |
23 # 1. The distance that matters here is not from the original | |
24 # call point to the destination, but from the stub to | |
25 # the destination - and in this function we don't know | |
26 # where the stub will end up. | |
27 # | |
28 # 2. Because it's an ARM branch, the limits should be | |
29 # ARM_MAX_[BF]WD_BRANCH_OFFSET, not the THM_ ones. | |
30 # | |
31 # The 2nd problem would be trivial to fix, but the 1st one | |
32 # much less so: this function doesn't know where the stub | |
33 # will end up, and considering that for the present purpose | |
34 # of the FreeCalypso project always emitting the "short" | |
35 # version would be perfect, there is no justification for | |
36 # expending the time and effort to restructure the linker | |
37 # to do the proper relaxation for the case at hand. | |
38 # | |
39 # Therefore, the patch we apply is a hack: we simply force the | |
40 # use of the "short" form unconditionally. | |
41 | |
42 *** elf32-arm.c Wed May 11 07:29:12 2011 | |
43 --- elf32-arm-patched.c Mon Aug 19 03:24:38 2013 | |
44 *************** | |
45 *** 3203,3211 **** | |
46 : arm_stub_long_branch_v4t_thumb_arm); | |
47 | |
48 /* Handle v4t short branches. */ | |
49 ! if ((stub_type == arm_stub_long_branch_v4t_thumb_arm) | |
50 ! && (branch_offset <= THM_MAX_FWD_BRANCH_OFFSET) | |
51 ! && (branch_offset >= THM_MAX_BWD_BRANCH_OFFSET)) | |
52 stub_type = arm_stub_short_branch_v4t_thumb_arm; | |
53 } | |
54 } | |
55 --- 3203,3209 ---- | |
56 : arm_stub_long_branch_v4t_thumb_arm); | |
57 | |
58 /* Handle v4t short branches. */ | |
59 ! if (stub_type == arm_stub_long_branch_v4t_thumb_arm) | |
60 stub_type = arm_stub_short_branch_v4t_thumb_arm; | |
61 } | |
62 } |