diff options
| author | Nathan Rossi <nathan.rossi@xilinx.com> | 2013-07-08 17:42:52 +1000 |
|---|---|---|
| committer | Nathan Rossi <nathan.rossi@xilinx.com> | 2013-07-08 17:42:52 +1000 |
| commit | 2500aa69b35b0817cc2fe989473e5fbee5524514 (patch) | |
| tree | 91199306a318e400fd63a99072c8d90ccc797881 /recipes-devtools/binutils/files/0013-19e05575d97b6dc83dae1b8309624da3102d7a74.patch | |
| parent | 1a3f269ade36b24085ce759ddf46da702406d27c (diff) | |
| download | meta-xilinx-2500aa69b35b0817cc2fe989473e5fbee5524514.tar.gz | |
binutils: Added MicroBlaze specific patches
* Patches are backported from upstream binutils
Signed-off-by: Nathan Rossi <nathan.rossi@xilinx.com>
Diffstat (limited to 'recipes-devtools/binutils/files/0013-19e05575d97b6dc83dae1b8309624da3102d7a74.patch')
| -rw-r--r-- | recipes-devtools/binutils/files/0013-19e05575d97b6dc83dae1b8309624da3102d7a74.patch | 310 |
1 files changed, 310 insertions, 0 deletions
diff --git a/recipes-devtools/binutils/files/0013-19e05575d97b6dc83dae1b8309624da3102d7a74.patch b/recipes-devtools/binutils/files/0013-19e05575d97b6dc83dae1b8309624da3102d7a74.patch new file mode 100644 index 00000000..a2154785 --- /dev/null +++ b/recipes-devtools/binutils/files/0013-19e05575d97b6dc83dae1b8309624da3102d7a74.patch | |||
| @@ -0,0 +1,310 @@ | |||
| 1 | From 19e05575d97b6dc83dae1b8309624da3102d7a74 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Michael Eager <eager@eagercon.com> | ||
| 3 | Date: Tue, 18 Dec 2012 16:01:00 +0000 | ||
| 4 | Subject: PR ld/14736 bfd: * elf32-microblaze.c (calc_fixup): Add end | ||
| 5 | range. gas/testsuite: * gas/microblaze/relax_size.exp: New file - | ||
| 6 | test object size after linker relaxation * | ||
| 7 | gas/microblaze/relax_size.s: Likewise * | ||
| 8 | gas/microblaze/relax_size.elf: Likewise * | ||
| 9 | gas/microblaze/relax_size2.s: Likewise * | ||
| 10 | gas/microblaze/relax_size2.elf: Likewise | ||
| 11 | |||
| 12 | Upstream-Status: Backport | ||
| 13 | |||
| 14 | diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c | ||
| 15 | index 9d0a7ca..8aafe72 100644 | ||
| 16 | --- a/bfd/elf32-microblaze.c | ||
| 17 | +++ b/bfd/elf32-microblaze.c | ||
| 18 | @@ -1600,8 +1600,9 @@ microblaze_elf_merge_private_bfd_data (bfd * ibfd, bfd * obfd) | ||
| 19 | /* Calculate fixup value for reference. */ | ||
| 20 | |||
| 21 | static int | ||
| 22 | -calc_fixup (bfd_vma addr, asection *sec) | ||
| 23 | +calc_fixup (bfd_vma start, bfd_vma size, asection *sec) | ||
| 24 | { | ||
| 25 | + bfd_vma end = start + size; | ||
| 26 | int i, fixup = 0; | ||
| 27 | |||
| 28 | if (sec == NULL || sec->relax == NULL) | ||
| 29 | @@ -1610,11 +1611,12 @@ calc_fixup (bfd_vma addr, asection *sec) | ||
| 30 | /* Look for addr in relax table, total fixup value. */ | ||
| 31 | for (i = 0; i < sec->relax_count; i++) | ||
| 32 | { | ||
| 33 | - if (addr <= sec->relax[i].addr) | ||
| 34 | + if (end <= sec->relax[i].addr) | ||
| 35 | break; | ||
| 36 | + if ((end != start) && (start > sec->relax[i].addr)) | ||
| 37 | + continue; | ||
| 38 | fixup += sec->relax[i].size; | ||
| 39 | } | ||
| 40 | - | ||
| 41 | return fixup; | ||
| 42 | } | ||
| 43 | |||
| 44 | @@ -1827,7 +1829,7 @@ microblaze_elf_relax_section (bfd *abfd, | ||
| 45 | bfd_vma nraddr; | ||
| 46 | |||
| 47 | /* Get the new reloc address. */ | ||
| 48 | - nraddr = irel->r_offset - calc_fixup (irel->r_offset, sec); | ||
| 49 | + nraddr = irel->r_offset - calc_fixup (irel->r_offset, 0, sec); | ||
| 50 | switch ((enum elf_microblaze_reloc_type) ELF32_R_TYPE (irel->r_info)) | ||
| 51 | { | ||
| 52 | default: | ||
| 53 | @@ -1845,7 +1847,7 @@ microblaze_elf_relax_section (bfd *abfd, | ||
| 54 | /* Only handle relocs against .text. */ | ||
| 55 | if (isym->st_shndx == shndx | ||
| 56 | && ELF32_ST_TYPE (isym->st_info) == STT_SECTION) | ||
| 57 | - irel->r_addend -= calc_fixup (irel->r_addend, sec); | ||
| 58 | + irel->r_addend -= calc_fixup (irel->r_addend, 0, sec); | ||
| 59 | } | ||
| 60 | break; | ||
| 61 | case R_MICROBLAZE_NONE: | ||
| 62 | @@ -1855,8 +1857,8 @@ microblaze_elf_relax_section (bfd *abfd, | ||
| 63 | int sfix, efix; | ||
| 64 | bfd_vma target_address; | ||
| 65 | target_address = irel->r_addend + irel->r_offset; | ||
| 66 | - sfix = calc_fixup (irel->r_offset, sec); | ||
| 67 | - efix = calc_fixup (target_address, sec); | ||
| 68 | + sfix = calc_fixup (irel->r_offset, 0, sec); | ||
| 69 | + efix = calc_fixup (target_address, 0, sec); | ||
| 70 | irel->r_addend -= (efix - sfix); | ||
| 71 | /* Should use HOWTO. */ | ||
| 72 | microblaze_bfd_write_imm_value_32 (abfd, contents + irel->r_offset, | ||
| 73 | @@ -1870,8 +1872,8 @@ microblaze_elf_relax_section (bfd *abfd, | ||
| 74 | int sfix, efix; | ||
| 75 | bfd_vma target_address; | ||
| 76 | target_address = irel->r_addend + irel->r_offset + INST_WORD_SIZE; | ||
| 77 | - sfix = calc_fixup (irel->r_offset + INST_WORD_SIZE, sec); | ||
| 78 | - efix = calc_fixup (target_address, sec); | ||
| 79 | + sfix = calc_fixup (irel->r_offset + INST_WORD_SIZE, 0, sec); | ||
| 80 | + efix = calc_fixup (target_address, 0, sec); | ||
| 81 | irel->r_addend -= (efix - sfix); | ||
| 82 | microblaze_bfd_write_imm_value_32 (abfd, contents + irel->r_offset | ||
| 83 | + INST_WORD_SIZE, irel->r_addend); | ||
| 84 | @@ -1934,7 +1936,7 @@ microblaze_elf_relax_section (bfd *abfd, | ||
| 85 | } | ||
| 86 | |||
| 87 | } | ||
| 88 | - irelscan->r_addend -= calc_fixup (irelscan->r_addend, sec); | ||
| 89 | + irelscan->r_addend -= calc_fixup (irelscan->r_addend, 0, sec); | ||
| 90 | } | ||
| 91 | else if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32_SYM_OP_SYM) | ||
| 92 | { | ||
| 93 | @@ -1965,6 +1967,7 @@ microblaze_elf_relax_section (bfd *abfd, | ||
| 94 | } | ||
| 95 | irelscan->r_addend -= calc_fixup (irel->r_addend | ||
| 96 | + isym->st_value, | ||
| 97 | + 0, | ||
| 98 | sec); | ||
| 99 | } | ||
| 100 | } | ||
| 101 | @@ -2005,7 +2008,7 @@ microblaze_elf_relax_section (bfd *abfd, | ||
| 102 | unsigned long instr = bfd_get_32 (abfd, ocontents + irelscan->r_offset); | ||
| 103 | immediate = instr & 0x0000ffff; | ||
| 104 | target_address = immediate; | ||
| 105 | - offset = calc_fixup (target_address, sec); | ||
| 106 | + offset = calc_fixup (target_address, 0, sec); | ||
| 107 | immediate -= offset; | ||
| 108 | irelscan->r_addend -= offset; | ||
| 109 | microblaze_bfd_write_imm_value_32 (abfd, ocontents + irelscan->r_offset, | ||
| 110 | @@ -2052,7 +2055,7 @@ microblaze_elf_relax_section (bfd *abfd, | ||
| 111 | + INST_WORD_SIZE); | ||
| 112 | immediate = (instr_hi & 0x0000ffff) << 16; | ||
| 113 | immediate |= (instr_lo & 0x0000ffff); | ||
| 114 | - offset = calc_fixup (irelscan->r_addend, sec); | ||
| 115 | + offset = calc_fixup (irelscan->r_addend, 0, sec); | ||
| 116 | immediate -= offset; | ||
| 117 | irelscan->r_addend -= offset; | ||
| 118 | } | ||
| 119 | @@ -2097,7 +2100,7 @@ microblaze_elf_relax_section (bfd *abfd, | ||
| 120 | immediate = (instr_hi & 0x0000ffff) << 16; | ||
| 121 | immediate |= (instr_lo & 0x0000ffff); | ||
| 122 | target_address = immediate; | ||
| 123 | - offset = calc_fixup (target_address, sec); | ||
| 124 | + offset = calc_fixup (target_address, 0, sec); | ||
| 125 | immediate -= offset; | ||
| 126 | irelscan->r_addend -= offset; | ||
| 127 | microblaze_bfd_write_imm_value_64 (abfd, ocontents | ||
| 128 | @@ -2112,24 +2115,30 @@ microblaze_elf_relax_section (bfd *abfd, | ||
| 129 | for (isym = isymbuf; isym < isymend; isym++) | ||
| 130 | { | ||
| 131 | if (isym->st_shndx == shndx) | ||
| 132 | - isym->st_value =- calc_fixup (isym->st_value, sec); | ||
| 133 | + { | ||
| 134 | + isym->st_value -= calc_fixup (isym->st_value, 0, sec); | ||
| 135 | + if (isym->st_size) | ||
| 136 | + isym->st_size -= calc_fixup (isym->st_value, isym->st_size, sec); | ||
| 137 | + } | ||
| 138 | } | ||
| 139 | |||
| 140 | /* Now adjust the global symbols defined in this section. */ | ||
| 141 | isym = isymbuf + symtab_hdr->sh_info; | ||
| 142 | - isymend = isymbuf + (symtab_hdr->sh_size / sizeof (Elf32_External_Sym)); | ||
| 143 | - for (sym_index = 0; isym < isymend; isym++, sym_index++) | ||
| 144 | + symcount = (symtab_hdr->sh_size / sizeof (Elf32_External_Sym)) - symtab_hdr->sh_info; | ||
| 145 | + for (sym_index = 0; sym_index < symcount; sym_index++) | ||
| 146 | { | ||
| 147 | sym_hash = elf_sym_hashes (abfd)[sym_index]; | ||
| 148 | - if (isym->st_shndx == shndx | ||
| 149 | - && (sym_hash->root.type == bfd_link_hash_defined | ||
| 150 | + if ((sym_hash->root.type == bfd_link_hash_defined | ||
| 151 | || sym_hash->root.type == bfd_link_hash_defweak) | ||
| 152 | && sym_hash->root.u.def.section == sec) | ||
| 153 | - { | ||
| 154 | - sym_hash->root.u.def.value -= calc_fixup (sym_hash->root.u.def.value, | ||
| 155 | - sec); | ||
| 156 | - } | ||
| 157 | - } | ||
| 158 | + { | ||
| 159 | + sym_hash->root.u.def.value -= calc_fixup (sym_hash->root.u.def.value, | ||
| 160 | + 0, sec); | ||
| 161 | + if (sym_hash->size) | ||
| 162 | + sym_hash->size -= calc_fixup (sym_hash->root.u.def.value, | ||
| 163 | + sym_hash->size, sec); | ||
| 164 | + } | ||
| 165 | + } | ||
| 166 | |||
| 167 | /* Physically move the code and change the cooked size. */ | ||
| 168 | dest = sec->relax[0].addr; | ||
| 169 | diff --git a/gas/testsuite/gas/microblaze/relax_size.elf b/gas/testsuite/gas/microblaze/relax_size.elf | ||
| 170 | new file mode 100644 | ||
| 171 | index 0000000..cf23ea6 | ||
| 172 | --- /dev/null | ||
| 173 | +++ b/gas/testsuite/gas/microblaze/relax_size.elf | ||
| 174 | @@ -0,0 +1,32 @@ | ||
| 175 | + | ||
| 176 | +Symbol table '.symtab' contains 29 entries: | ||
| 177 | + Num: Value Size Type Bind Vis Ndx Name | ||
| 178 | + 0: 00000000 0 NOTYPE LOCAL DEFAULT UND | ||
| 179 | + 1: 00000050 0 SECTION LOCAL DEFAULT 1 | ||
| 180 | + 2: 00000058 0 SECTION LOCAL DEFAULT 2 | ||
| 181 | + 3: 00000000 0 FILE LOCAL DEFAULT ABS relax_size.o | ||
| 182 | + 4: 00000050 8 NOTYPE LOCAL DEFAULT 1 func | ||
| 183 | + 5: 00000058 0 NOTYPE LOCAL DEFAULT 1 label | ||
| 184 | + 6: 00000000 0 FILE LOCAL DEFAULT ABS | ||
| 185 | + 7: 00000058 0 NOTYPE GLOBAL DEFAULT 2 _fdata | ||
| 186 | + 8: 00000058 0 NOTYPE GLOBAL DEFAULT 1 _etext | ||
| 187 | + 9: 00000058 0 NOTYPE GLOBAL DEFAULT 2 _essrw | ||
| 188 | + 10: 00000058 0 NOTYPE GLOBAL DEFAULT 1 _heap_end | ||
| 189 | + 11: 00000058 0 NOTYPE GLOBAL DEFAULT 1 _heap_start | ||
| 190 | + 12: 00000000 0 NOTYPE GLOBAL DEFAULT ABS _ssro_size | ||
| 191 | + 13: 00000050 0 NOTYPE GLOBAL DEFAULT 1 _ftext | ||
| 192 | + 14: 00000058 0 NOTYPE GLOBAL DEFAULT 2 _essro | ||
| 193 | + 15: 00000400 0 NOTYPE GLOBAL DEFAULT ABS _STACK_SIZE | ||
| 194 | + 16: 00000000 0 NOTYPE GLOBAL DEFAULT ABS _HEAP_SIZE | ||
| 195 | + 17: 00000000 0 NOTYPE GLOBAL DEFAULT ABS _ssrw_size | ||
| 196 | + 18: 00000058 0 NOTYPE GLOBAL DEFAULT 2 _stack_end | ||
| 197 | + 19: 00000058 0 NOTYPE GLOBAL DEFAULT 2 _edata | ||
| 198 | + 20: 00000458 0 NOTYPE GLOBAL DEFAULT 2 _end | ||
| 199 | + 21: 00000058 0 NOTYPE GLOBAL DEFAULT 1 _heap | ||
| 200 | + 22: 00000058 0 NOTYPE GLOBAL DEFAULT 2 _ssro | ||
| 201 | + 23: 00000058 0 NOTYPE GLOBAL DEFAULT 2 _ssrw | ||
| 202 | + 24: 00000458 0 NOTYPE GLOBAL DEFAULT 2 _stack | ||
| 203 | + 25: 00000050 0 NOTYPE GLOBAL DEFAULT ABS _TEXT_START_ADDR | ||
| 204 | + 26: 00000058 0 NOTYPE GLOBAL DEFAULT 2 _frodata | ||
| 205 | + 27: 00000058 0 NOTYPE GLOBAL DEFAULT 2 _fbss | ||
| 206 | + 28: 00000058 0 NOTYPE GLOBAL DEFAULT 2 _erodata | ||
| 207 | diff --git a/gas/testsuite/gas/microblaze/relax_size.exp b/gas/testsuite/gas/microblaze/relax_size.exp | ||
| 208 | new file mode 100644 | ||
| 209 | index 0000000..a733dc8 | ||
| 210 | --- /dev/null | ||
| 211 | +++ b/gas/testsuite/gas/microblaze/relax_size.exp | ||
| 212 | @@ -0,0 +1,25 @@ | ||
| 213 | + | ||
| 214 | +proc ld_run { objects ldflags dest test } { | ||
| 215 | + set ld_output [target_link $objects $dest $ldflags] | ||
| 216 | +} | ||
| 217 | + | ||
| 218 | +proc readelf_run { exec flags dest test } { | ||
| 219 | + set readelf [find_binutils_prog readelf] | ||
| 220 | + verbose -log "$readelf $flags $exec > $dest" | ||
| 221 | + catch "exec $readelf $flags $exec > $dest" readelf_output | ||
| 222 | +} | ||
| 223 | + | ||
| 224 | +proc regexp_test { file1 file2 test } { | ||
| 225 | + if [regexp_diff $file1 $file2] then { fail $test } else { pass $test } | ||
| 226 | +} | ||
| 227 | + | ||
| 228 | +global srcdir subdir | ||
| 229 | +if [istarget microblaze*-*-elf] { | ||
| 230 | + foreach file [lsort [glob -nocomplain -- $srcdir/$subdir/relax_size*.s]] { | ||
| 231 | + set file [file rootname [file tail $file]] | ||
| 232 | + gas_run "$file.s" "-o $file.o" "" | ||
| 233 | + ld_run "$file.o" "-e 0 -N -relax" "$file.x" "linking $file.x" | ||
| 234 | + readelf_run "$file.x" "-s" "$file.elf" "readelf -s $file.x" | ||
| 235 | + regexp_test "$file.elf" "$srcdir/$subdir/$file.elf" "matching $file.elf" | ||
| 236 | + } | ||
| 237 | +} | ||
| 238 | diff --git a/gas/testsuite/gas/microblaze/relax_size.s b/gas/testsuite/gas/microblaze/relax_size.s | ||
| 239 | new file mode 100644 | ||
| 240 | index 0000000..6b25977 | ||
| 241 | --- /dev/null | ||
| 242 | +++ b/gas/testsuite/gas/microblaze/relax_size.s | ||
| 243 | @@ -0,0 +1,7 @@ | ||
| 244 | + .org 0 | ||
| 245 | + .section .text | ||
| 246 | +func: | ||
| 247 | + braid label | ||
| 248 | + nop | ||
| 249 | +label: | ||
| 250 | + .size func, . - func | ||
| 251 | diff --git a/gas/testsuite/gas/microblaze/relax_size2.elf b/gas/testsuite/gas/microblaze/relax_size2.elf | ||
| 252 | new file mode 100644 | ||
| 253 | index 0000000..fbdcc0a | ||
| 254 | --- /dev/null | ||
| 255 | +++ b/gas/testsuite/gas/microblaze/relax_size2.elf | ||
| 256 | @@ -0,0 +1,34 @@ | ||
| 257 | + | ||
| 258 | +Symbol table '.symtab' contains 31 entries: | ||
| 259 | + Num: Value Size Type Bind Vis Ndx Name | ||
| 260 | + 0: 00000000 0 NOTYPE LOCAL DEFAULT UND | ||
| 261 | + 1: 00000050 0 SECTION LOCAL DEFAULT 1 | ||
| 262 | + 2: 00000060 0 SECTION LOCAL DEFAULT 2 | ||
| 263 | + 3: 00000000 0 FILE LOCAL DEFAULT ABS relax_size2.o | ||
| 264 | + 4: 00000050 4 NOTYPE LOCAL DEFAULT 1 func | ||
| 265 | + 5: 00000054 0 NOTYPE LOCAL DEFAULT 1 label | ||
| 266 | + 6: 00000054 8 NOTYPE LOCAL DEFAULT 1 func2 | ||
| 267 | + 7: 0000005c 0 NOTYPE LOCAL DEFAULT 1 label2 | ||
| 268 | + 8: 00000000 0 FILE LOCAL DEFAULT ABS | ||
| 269 | + 9: 00000060 0 NOTYPE GLOBAL DEFAULT 2 _fdata | ||
| 270 | + 10: 0000005c 0 NOTYPE GLOBAL DEFAULT 1 _etext | ||
| 271 | + 11: 00000060 0 NOTYPE GLOBAL DEFAULT 2 _essrw | ||
| 272 | + 12: 00000060 0 NOTYPE GLOBAL DEFAULT 1 _heap_end | ||
| 273 | + 13: 00000060 0 NOTYPE GLOBAL DEFAULT 1 _heap_start | ||
| 274 | + 14: 00000000 0 NOTYPE GLOBAL DEFAULT ABS _ssro_size | ||
| 275 | + 15: 00000050 0 NOTYPE GLOBAL DEFAULT 1 _ftext | ||
| 276 | + 16: 00000060 0 NOTYPE GLOBAL DEFAULT 2 _essro | ||
| 277 | + 17: 00000400 0 NOTYPE GLOBAL DEFAULT ABS _STACK_SIZE | ||
| 278 | + 18: 00000000 0 NOTYPE GLOBAL DEFAULT ABS _HEAP_SIZE | ||
| 279 | + 19: 00000000 0 NOTYPE GLOBAL DEFAULT ABS _ssrw_size | ||
| 280 | + 20: 00000060 0 NOTYPE GLOBAL DEFAULT 2 _stack_end | ||
| 281 | + 21: 00000060 0 NOTYPE GLOBAL DEFAULT 2 _edata | ||
| 282 | + 22: 00000460 0 NOTYPE GLOBAL DEFAULT 2 _end | ||
| 283 | + 23: 00000060 0 NOTYPE GLOBAL DEFAULT 1 _heap | ||
| 284 | + 24: 00000060 0 NOTYPE GLOBAL DEFAULT 2 _ssro | ||
| 285 | + 25: 00000060 0 NOTYPE GLOBAL DEFAULT 2 _ssrw | ||
| 286 | + 26: 00000460 0 NOTYPE GLOBAL DEFAULT 2 _stack | ||
| 287 | + 27: 00000050 0 NOTYPE GLOBAL DEFAULT ABS _TEXT_START_ADDR | ||
| 288 | + 28: 0000005c 0 NOTYPE GLOBAL DEFAULT 2 _frodata | ||
| 289 | + 29: 00000060 0 NOTYPE GLOBAL DEFAULT 2 _fbss | ||
| 290 | + 30: 0000005c 0 NOTYPE GLOBAL DEFAULT 2 _erodata | ||
| 291 | diff --git a/gas/testsuite/gas/microblaze/relax_size2.s b/gas/testsuite/gas/microblaze/relax_size2.s | ||
| 292 | new file mode 100644 | ||
| 293 | index 0000000..dedabfb | ||
| 294 | --- /dev/null | ||
| 295 | +++ b/gas/testsuite/gas/microblaze/relax_size2.s | ||
| 296 | @@ -0,0 +1,11 @@ | ||
| 297 | + .org 0 | ||
| 298 | + .section .text | ||
| 299 | +func: | ||
| 300 | + nop | ||
| 301 | +label: | ||
| 302 | + .size func, . - func | ||
| 303 | +func2: | ||
| 304 | + braid label2 | ||
| 305 | + nop | ||
| 306 | +label2: | ||
| 307 | + .size func2, . - func2 | ||
| 308 | -- | ||
| 309 | 1.7.5.4 | ||
| 310 | |||
