| 1 | /* i370-specific support for 32-bit ELF | 
|---|
| 2 | Copyright 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002 | 
|---|
| 3 | Free Software Foundation, Inc. | 
|---|
| 4 | Written by Ian Lance Taylor, Cygnus Support. | 
|---|
| 5 | Hacked by Linas Vepstas for i370 linas@linas.org | 
|---|
| 6 |  | 
|---|
| 7 | This file is part of BFD, the Binary File Descriptor library. | 
|---|
| 8 |  | 
|---|
| 9 | This program is free software; you can redistribute it and/or modify | 
|---|
| 10 | it under the terms of the GNU General Public License as published by | 
|---|
| 11 | the Free Software Foundation; either version 2 of the License, or | 
|---|
| 12 | (at your option) any later version. | 
|---|
| 13 |  | 
|---|
| 14 | This program is distributed in the hope that it will be useful, | 
|---|
| 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
| 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
| 17 | GNU General Public License for more details. | 
|---|
| 18 |  | 
|---|
| 19 | You should have received a copy of the GNU General Public License | 
|---|
| 20 | along with this program; if not, write to the Free Software | 
|---|
| 21 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */ | 
|---|
| 22 |  | 
|---|
| 23 | /* This file is based on a preliminary PowerPC ELF ABI. | 
|---|
| 24 | But its been hacked on for the IBM 360/370 architectures. | 
|---|
| 25 | Basically, the 31bit relocation works, and just about everything | 
|---|
| 26 | else is a wild card.  In particular, don't expect shared libs or | 
|---|
| 27 | dynamic loading to work ...  its never been tested ... | 
|---|
| 28 | */ | 
|---|
| 29 |  | 
|---|
| 30 | #include "bfd.h" | 
|---|
| 31 | #include "sysdep.h" | 
|---|
| 32 | #include "bfdlink.h" | 
|---|
| 33 | #include "libbfd.h" | 
|---|
| 34 | #include "elf-bfd.h" | 
|---|
| 35 | #include "elf/i370.h" | 
|---|
| 36 |  | 
|---|
| 37 | static reloc_howto_type *i370_elf_howto_table[ (int)R_I370_max ]; | 
|---|
| 38 |  | 
|---|
| 39 | static reloc_howto_type i370_elf_howto_raw[] = | 
|---|
| 40 | { | 
|---|
| 41 | /* This reloc does nothing.  */ | 
|---|
| 42 | HOWTO (R_I370_NONE,           /* type */ | 
|---|
| 43 | 0,                     /* rightshift */ | 
|---|
| 44 | 2,                     /* size (0 = byte, 1 = short, 2 = long) */ | 
|---|
| 45 | 32,                    /* bitsize */ | 
|---|
| 46 | FALSE,                 /* pc_relative */ | 
|---|
| 47 | 0,                     /* bitpos */ | 
|---|
| 48 | complain_overflow_bitfield, /* complain_on_overflow */ | 
|---|
| 49 | bfd_elf_generic_reloc, /* special_function */ | 
|---|
| 50 | "R_I370_NONE",         /* name */ | 
|---|
| 51 | FALSE,                 /* partial_inplace */ | 
|---|
| 52 | 0,                     /* src_mask */ | 
|---|
| 53 | 0,                     /* dst_mask */ | 
|---|
| 54 | FALSE),                /* pcrel_offset */ | 
|---|
| 55 |  | 
|---|
| 56 | /* A standard 31 bit relocation.  */ | 
|---|
| 57 | HOWTO (R_I370_ADDR31,         /* type */ | 
|---|
| 58 | 0,                     /* rightshift */ | 
|---|
| 59 | 2,                     /* size (0 = byte, 1 = short, 2 = long) */ | 
|---|
| 60 | 31,                    /* bitsize */ | 
|---|
| 61 | FALSE,                 /* pc_relative */ | 
|---|
| 62 | 0,                     /* bitpos */ | 
|---|
| 63 | complain_overflow_bitfield, /* complain_on_overflow */ | 
|---|
| 64 | bfd_elf_generic_reloc, /* special_function */ | 
|---|
| 65 | "R_I370_ADDR31",       /* name */ | 
|---|
| 66 | FALSE,                 /* partial_inplace */ | 
|---|
| 67 | 0,                     /* src_mask */ | 
|---|
| 68 | 0x7fffffff,            /* dst_mask */ | 
|---|
| 69 | FALSE),                /* pcrel_offset */ | 
|---|
| 70 |  | 
|---|
| 71 | /* A standard 32 bit relocation.  */ | 
|---|
| 72 | HOWTO (R_I370_ADDR32,         /* type */ | 
|---|
| 73 | 0,                     /* rightshift */ | 
|---|
| 74 | 2,                     /* size (0 = byte, 1 = short, 2 = long) */ | 
|---|
| 75 | 32,                    /* bitsize */ | 
|---|
| 76 | FALSE,                 /* pc_relative */ | 
|---|
| 77 | 0,                     /* bitpos */ | 
|---|
| 78 | complain_overflow_bitfield, /* complain_on_overflow */ | 
|---|
| 79 | bfd_elf_generic_reloc, /* special_function */ | 
|---|
| 80 | "R_I370_ADDR32",       /* name */ | 
|---|
| 81 | FALSE,                 /* partial_inplace */ | 
|---|
| 82 | 0,                     /* src_mask */ | 
|---|
| 83 | 0xffffffff,            /* dst_mask */ | 
|---|
| 84 | FALSE),                /* pcrel_offset */ | 
|---|
| 85 |  | 
|---|
| 86 | /* A standard 16 bit relocation.  */ | 
|---|
| 87 | HOWTO (R_I370_ADDR16,         /* type */ | 
|---|
| 88 | 0,                     /* rightshift */ | 
|---|
| 89 | 1,                     /* size (0 = byte, 1 = short, 2 = long) */ | 
|---|
| 90 | 16,                    /* bitsize */ | 
|---|
| 91 | FALSE,                 /* pc_relative */ | 
|---|
| 92 | 0,                     /* bitpos */ | 
|---|
| 93 | complain_overflow_bitfield, /* complain_on_overflow */ | 
|---|
| 94 | bfd_elf_generic_reloc, /* special_function */ | 
|---|
| 95 | "R_I370_ADDR16",       /* name */ | 
|---|
| 96 | FALSE,                 /* partial_inplace */ | 
|---|
| 97 | 0,                     /* src_mask */ | 
|---|
| 98 | 0xffff,                /* dst_mask */ | 
|---|
| 99 | FALSE),                /* pcrel_offset */ | 
|---|
| 100 |  | 
|---|
| 101 | /* 31-bit PC relative */ | 
|---|
| 102 | HOWTO (R_I370_REL31,          /* type */ | 
|---|
| 103 | 0,                     /* rightshift */ | 
|---|
| 104 | 2,                     /* size (0 = byte, 1 = short, 2 = long) */ | 
|---|
| 105 | 31,                    /* bitsize */ | 
|---|
| 106 | TRUE,                  /* pc_relative */ | 
|---|
| 107 | 0,                     /* bitpos */ | 
|---|
| 108 | complain_overflow_bitfield, /* complain_on_overflow */ | 
|---|
| 109 | bfd_elf_generic_reloc, /* special_function */ | 
|---|
| 110 | "R_I370_REL31",        /* name */ | 
|---|
| 111 | FALSE,                 /* partial_inplace */ | 
|---|
| 112 | 0,                     /* src_mask */ | 
|---|
| 113 | 0x7fffffff,            /* dst_mask */ | 
|---|
| 114 | TRUE),                 /* pcrel_offset */ | 
|---|
| 115 |  | 
|---|
| 116 | /* 32-bit PC relative */ | 
|---|
| 117 | HOWTO (R_I370_REL32,          /* type */ | 
|---|
| 118 | 0,                     /* rightshift */ | 
|---|
| 119 | 2,                     /* size (0 = byte, 1 = short, 2 = long) */ | 
|---|
| 120 | 32,                    /* bitsize */ | 
|---|
| 121 | TRUE,                  /* pc_relative */ | 
|---|
| 122 | 0,                     /* bitpos */ | 
|---|
| 123 | complain_overflow_bitfield, /* complain_on_overflow */ | 
|---|
| 124 | bfd_elf_generic_reloc, /* special_function */ | 
|---|
| 125 | "R_I370_REL32",        /* name */ | 
|---|
| 126 | FALSE,                 /* partial_inplace */ | 
|---|
| 127 | 0,                     /* src_mask */ | 
|---|
| 128 | 0xffffffff,            /* dst_mask */ | 
|---|
| 129 | TRUE),                 /* pcrel_offset */ | 
|---|
| 130 |  | 
|---|
| 131 | /* A standard 12 bit relocation.  */ | 
|---|
| 132 | HOWTO (R_I370_ADDR12,         /* type */ | 
|---|
| 133 | 0,                     /* rightshift */ | 
|---|
| 134 | 1,                     /* size (0 = byte, 1 = short, 2 = long) */ | 
|---|
| 135 | 12,                    /* bitsize */ | 
|---|
| 136 | FALSE,                 /* pc_relative */ | 
|---|
| 137 | 0,                     /* bitpos */ | 
|---|
| 138 | complain_overflow_bitfield, /* complain_on_overflow */ | 
|---|
| 139 | bfd_elf_generic_reloc, /* special_function */ | 
|---|
| 140 | "R_I370_ADDR12",       /* name */ | 
|---|
| 141 | FALSE,                 /* partial_inplace */ | 
|---|
| 142 | 0,                     /* src_mask */ | 
|---|
| 143 | 0xfff,                 /* dst_mask */ | 
|---|
| 144 | FALSE),                /* pcrel_offset */ | 
|---|
| 145 |  | 
|---|
| 146 | /* 12-bit PC relative */ | 
|---|
| 147 | HOWTO (R_I370_REL12,          /* type */ | 
|---|
| 148 | 0,                     /* rightshift */ | 
|---|
| 149 | 1,                     /* size (0 = byte, 1 = short, 2 = long) */ | 
|---|
| 150 | 12,                    /* bitsize */ | 
|---|
| 151 | TRUE,                  /* pc_relative */ | 
|---|
| 152 | 0,                     /* bitpos */ | 
|---|
| 153 | complain_overflow_bitfield, /* complain_on_overflow */ | 
|---|
| 154 | bfd_elf_generic_reloc, /* special_function */ | 
|---|
| 155 | "R_I370_REL12",        /* name */ | 
|---|
| 156 | FALSE,                 /* partial_inplace */ | 
|---|
| 157 | 0,                     /* src_mask */ | 
|---|
| 158 | 0xfff,                 /* dst_mask */ | 
|---|
| 159 | TRUE),                 /* pcrel_offset */ | 
|---|
| 160 |  | 
|---|
| 161 | /* A standard 8 bit relocation.  */ | 
|---|
| 162 | HOWTO (R_I370_ADDR8,          /* type */ | 
|---|
| 163 | 0,                     /* rightshift */ | 
|---|
| 164 | 0,                     /* size (0 = byte, 1 = short, 2 = long) */ | 
|---|
| 165 | 8,                     /* bitsize */ | 
|---|
| 166 | FALSE,                 /* pc_relative */ | 
|---|
| 167 | 0,                     /* bitpos */ | 
|---|
| 168 | complain_overflow_bitfield, /* complain_on_overflow */ | 
|---|
| 169 | bfd_elf_generic_reloc, /* special_function */ | 
|---|
| 170 | "R_I370_ADDR8",        /* name */ | 
|---|
| 171 | FALSE,                 /* partial_inplace */ | 
|---|
| 172 | 0,                     /* src_mask */ | 
|---|
| 173 | 0xff,                  /* dst_mask */ | 
|---|
| 174 | FALSE),                /* pcrel_offset */ | 
|---|
| 175 |  | 
|---|
| 176 | /* 8-bit PC relative */ | 
|---|
| 177 | HOWTO (R_I370_REL8,           /* type */ | 
|---|
| 178 | 0,                     /* rightshift */ | 
|---|
| 179 | 0,                     /* size (0 = byte, 1 = short, 2 = long) */ | 
|---|
| 180 | 8,                     /* bitsize */ | 
|---|
| 181 | TRUE,                  /* pc_relative */ | 
|---|
| 182 | 0,                     /* bitpos */ | 
|---|
| 183 | complain_overflow_bitfield, /* complain_on_overflow */ | 
|---|
| 184 | bfd_elf_generic_reloc, /* special_function */ | 
|---|
| 185 | "R_I370_REL8",         /* name */ | 
|---|
| 186 | FALSE,                 /* partial_inplace */ | 
|---|
| 187 | 0,                     /* src_mask */ | 
|---|
| 188 | 0xff,                  /* dst_mask */ | 
|---|
| 189 | TRUE),                 /* pcrel_offset */ | 
|---|
| 190 |  | 
|---|
| 191 | /* This is used only by the dynamic linker.  The symbol should exist | 
|---|
| 192 | both in the object being run and in some shared library.  The | 
|---|
| 193 | dynamic linker copies the data addressed by the symbol from the | 
|---|
| 194 | shared library into the object, because the object being | 
|---|
| 195 | run has to have the data at some particular address.  */ | 
|---|
| 196 | HOWTO (R_I370_COPY,           /* type */ | 
|---|
| 197 | 0,                     /* rightshift */ | 
|---|
| 198 | 2,                     /* size (0 = byte, 1 = short, 2 = long) */ | 
|---|
| 199 | 32,                    /* bitsize */ | 
|---|
| 200 | FALSE,                 /* pc_relative */ | 
|---|
| 201 | 0,                     /* bitpos */ | 
|---|
| 202 | complain_overflow_bitfield, /* complain_on_overflow */ | 
|---|
| 203 | bfd_elf_generic_reloc,  /* special_function */ | 
|---|
| 204 | "R_I370_COPY",         /* name */ | 
|---|
| 205 | FALSE,                 /* partial_inplace */ | 
|---|
| 206 | 0,                     /* src_mask */ | 
|---|
| 207 | 0,                     /* dst_mask */ | 
|---|
| 208 | FALSE),                /* pcrel_offset */ | 
|---|
| 209 |  | 
|---|
| 210 | /* Used only by the dynamic linker.  When the object is run, this | 
|---|
| 211 | longword is set to the load address of the object, plus the | 
|---|
| 212 | addend.  */ | 
|---|
| 213 | HOWTO (R_I370_RELATIVE,       /* type */ | 
|---|
| 214 | 0,                     /* rightshift */ | 
|---|
| 215 | 2,                     /* size (0 = byte, 1 = short, 2 = long) */ | 
|---|
| 216 | 32,                    /* bitsize */ | 
|---|
| 217 | FALSE,                 /* pc_relative */ | 
|---|
| 218 | 0,                     /* bitpos */ | 
|---|
| 219 | complain_overflow_bitfield, /* complain_on_overflow */ | 
|---|
| 220 | bfd_elf_generic_reloc,  /* special_function */ | 
|---|
| 221 | "R_I370_RELATIVE",     /* name */ | 
|---|
| 222 | FALSE,                 /* partial_inplace */ | 
|---|
| 223 | 0,                     /* src_mask */ | 
|---|
| 224 | 0xffffffff,            /* dst_mask */ | 
|---|
| 225 | FALSE),                /* pcrel_offset */ | 
|---|
| 226 |  | 
|---|
| 227 | }; | 
|---|
| 228 |  | 
|---|
| 229 |  | 
|---|
| 230 | static void i370_elf_howto_init | 
|---|
| 231 | PARAMS ((void)); | 
|---|
| 232 | static reloc_howto_type *i370_elf_reloc_type_lookup | 
|---|
| 233 | PARAMS ((bfd *, bfd_reloc_code_real_type)); | 
|---|
| 234 | static void i370_elf_info_to_howto | 
|---|
| 235 | PARAMS ((bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst)); | 
|---|
| 236 | static bfd_boolean i370_elf_set_private_flags | 
|---|
| 237 | PARAMS ((bfd *, flagword)); | 
|---|
| 238 |  | 
|---|
| 239 |  | 
|---|
| 240 | /* Initialize the i370_elf_howto_table, so that linear accesses can be done.  */ | 
|---|
| 241 |  | 
|---|
| 242 | static void | 
|---|
| 243 | i370_elf_howto_init () | 
|---|
| 244 | { | 
|---|
| 245 | unsigned int i, type; | 
|---|
| 246 |  | 
|---|
| 247 | for (i = 0; i < sizeof (i370_elf_howto_raw) / sizeof (i370_elf_howto_raw[0]); i++) | 
|---|
| 248 | { | 
|---|
| 249 | type = i370_elf_howto_raw[i].type; | 
|---|
| 250 | BFD_ASSERT (type < sizeof (i370_elf_howto_table) / sizeof (i370_elf_howto_table[0])); | 
|---|
| 251 | i370_elf_howto_table[type] = &i370_elf_howto_raw[i]; | 
|---|
| 252 | } | 
|---|
| 253 | } | 
|---|
| 254 |  | 
|---|
| 255 |  | 
|---|
| 256 | static reloc_howto_type * | 
|---|
| 257 | i370_elf_reloc_type_lookup (abfd, code) | 
|---|
| 258 | bfd *abfd ATTRIBUTE_UNUSED; | 
|---|
| 259 | bfd_reloc_code_real_type code; | 
|---|
| 260 | { | 
|---|
| 261 | enum i370_reloc_type i370_reloc = R_I370_NONE; | 
|---|
| 262 |  | 
|---|
| 263 | if (!i370_elf_howto_table[ R_I370_ADDR31 ])   /* Initialize howto table if needed */ | 
|---|
| 264 | i370_elf_howto_init (); | 
|---|
| 265 |  | 
|---|
| 266 | switch ((int)code) | 
|---|
| 267 | { | 
|---|
| 268 | default: | 
|---|
| 269 | return (reloc_howto_type *)NULL; | 
|---|
| 270 |  | 
|---|
| 271 | case BFD_RELOC_NONE:        i370_reloc = R_I370_NONE;       break; | 
|---|
| 272 | case BFD_RELOC_32:          i370_reloc = R_I370_ADDR31;     break; | 
|---|
| 273 | case BFD_RELOC_16:          i370_reloc = R_I370_ADDR16;     break; | 
|---|
| 274 | case BFD_RELOC_32_PCREL:    i370_reloc = R_I370_REL31;      break; | 
|---|
| 275 | case BFD_RELOC_CTOR:        i370_reloc = R_I370_ADDR31;     break; | 
|---|
| 276 | case BFD_RELOC_I370_D12:    i370_reloc = R_I370_ADDR12;     break; | 
|---|
| 277 | } | 
|---|
| 278 |  | 
|---|
| 279 | return i370_elf_howto_table[ (int)i370_reloc ]; | 
|---|
| 280 | }; | 
|---|
| 281 |  | 
|---|
| 282 | static bfd_boolean i370_elf_merge_private_bfd_data | 
|---|
| 283 | PARAMS ((bfd *, bfd *)); | 
|---|
| 284 | static bfd_boolean i370_elf_relocate_section | 
|---|
| 285 | PARAMS ((bfd *, struct bfd_link_info *info, bfd *, asection *, bfd_byte *, | 
|---|
| 286 | Elf_Internal_Rela *relocs, Elf_Internal_Sym *local_syms, | 
|---|
| 287 | asection **)); | 
|---|
| 288 | static void i370_elf_post_process_headers | 
|---|
| 289 | PARAMS ((bfd *, struct bfd_link_info *)); | 
|---|
| 290 | static bfd_boolean i370_elf_create_dynamic_sections | 
|---|
| 291 | PARAMS ((bfd *, struct bfd_link_info *)); | 
|---|
| 292 | static bfd_boolean i370_elf_section_from_shdr | 
|---|
| 293 | PARAMS ((bfd *, Elf_Internal_Shdr *, const char *)); | 
|---|
| 294 | static bfd_boolean i370_elf_fake_sections | 
|---|
| 295 | PARAMS ((bfd *, Elf_Internal_Shdr *, asection *)); | 
|---|
| 296 | #if 0 | 
|---|
| 297 | static elf_linker_section_t *i370_elf_create_linker_section | 
|---|
| 298 | PARAMS ((bfd *abfd, struct bfd_link_info *info, | 
|---|
| 299 | enum elf_linker_section_enum)); | 
|---|
| 300 | #endif | 
|---|
| 301 | static bfd_boolean i370_elf_check_relocs | 
|---|
| 302 | PARAMS ((bfd *, struct bfd_link_info *, asection *, | 
|---|
| 303 | const Elf_Internal_Rela *)); | 
|---|
| 304 | static bfd_boolean i370_elf_adjust_dynamic_symbol | 
|---|
| 305 | PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *)); | 
|---|
| 306 | static bfd_boolean i370_elf_adjust_dynindx | 
|---|
| 307 | PARAMS ((struct elf_link_hash_entry *, PTR)); | 
|---|
| 308 | static bfd_boolean i370_elf_size_dynamic_sections | 
|---|
| 309 | PARAMS ((bfd *, struct bfd_link_info *)); | 
|---|
| 310 | static bfd_boolean i370_elf_finish_dynamic_sections | 
|---|
| 311 | PARAMS ((bfd *, struct bfd_link_info *)); | 
|---|
| 312 |  | 
|---|
| 313 | /* The name of the dynamic interpreter.  This is put in the .interp | 
|---|
| 314 | section.  */ | 
|---|
| 315 |  | 
|---|
| 316 | #define ELF_DYNAMIC_INTERPRETER "/lib/ld.so" | 
|---|
| 317 |  | 
|---|
| 318 | /* Set the howto pointer for an i370 ELF reloc.  */ | 
|---|
| 319 |  | 
|---|
| 320 | static void | 
|---|
| 321 | i370_elf_info_to_howto (abfd, cache_ptr, dst) | 
|---|
| 322 | bfd *abfd ATTRIBUTE_UNUSED; | 
|---|
| 323 | arelent *cache_ptr; | 
|---|
| 324 | Elf_Internal_Rela *dst; | 
|---|
| 325 | { | 
|---|
| 326 | if (!i370_elf_howto_table[ R_I370_ADDR31 ])   /* Initialize howto table */ | 
|---|
| 327 | i370_elf_howto_init (); | 
|---|
| 328 |  | 
|---|
| 329 | BFD_ASSERT (ELF32_R_TYPE (dst->r_info) < (unsigned int) R_I370_max); | 
|---|
| 330 | cache_ptr->howto = i370_elf_howto_table[ELF32_R_TYPE (dst->r_info)]; | 
|---|
| 331 | } | 
|---|
| 332 |  | 
|---|
| 333 | /* hack alert --  the following several routines look generic to me ... | 
|---|
| 334 | * why are we bothering with them ??? | 
|---|
| 335 | */ | 
|---|
| 336 | /* Function to set whether a module needs the -mrelocatable bit set.  */ | 
|---|
| 337 | static bfd_boolean | 
|---|
| 338 | i370_elf_set_private_flags (abfd, flags) | 
|---|
| 339 | bfd *abfd; | 
|---|
| 340 | flagword flags; | 
|---|
| 341 | { | 
|---|
| 342 | BFD_ASSERT (!elf_flags_init (abfd) | 
|---|
| 343 | || elf_elfheader (abfd)->e_flags == flags); | 
|---|
| 344 |  | 
|---|
| 345 | elf_elfheader (abfd)->e_flags = flags; | 
|---|
| 346 | elf_flags_init (abfd) = TRUE; | 
|---|
| 347 | return TRUE; | 
|---|
| 348 | } | 
|---|
| 349 |  | 
|---|
| 350 | /* Merge backend specific data from an object file to the output | 
|---|
| 351 | object file when linking */ | 
|---|
| 352 | static bfd_boolean | 
|---|
| 353 | i370_elf_merge_private_bfd_data (ibfd, obfd) | 
|---|
| 354 | bfd *ibfd; | 
|---|
| 355 | bfd *obfd; | 
|---|
| 356 | { | 
|---|
| 357 | flagword old_flags; | 
|---|
| 358 | flagword new_flags; | 
|---|
| 359 |  | 
|---|
| 360 | if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour | 
|---|
| 361 | || bfd_get_flavour (obfd) != bfd_target_elf_flavour) | 
|---|
| 362 | return TRUE; | 
|---|
| 363 |  | 
|---|
| 364 | new_flags = elf_elfheader (ibfd)->e_flags; | 
|---|
| 365 | old_flags = elf_elfheader (obfd)->e_flags; | 
|---|
| 366 | if (!elf_flags_init (obfd))   /* First call, no flags set */ | 
|---|
| 367 | { | 
|---|
| 368 | elf_flags_init (obfd) = TRUE; | 
|---|
| 369 | elf_elfheader (obfd)->e_flags = new_flags; | 
|---|
| 370 | } | 
|---|
| 371 |  | 
|---|
| 372 | else if (new_flags == old_flags)      /* Compatible flags are ok */ | 
|---|
| 373 | ; | 
|---|
| 374 |  | 
|---|
| 375 | else                                  /* Incompatible flags */ | 
|---|
| 376 | { | 
|---|
| 377 | (*_bfd_error_handler) | 
|---|
| 378 | ("%s: uses different e_flags (0x%lx) fields than previous modules (0x%lx)", | 
|---|
| 379 | bfd_archive_filename (ibfd), (long) new_flags, (long) old_flags); | 
|---|
| 380 |  | 
|---|
| 381 | bfd_set_error (bfd_error_bad_value); | 
|---|
| 382 | return FALSE; | 
|---|
| 383 | } | 
|---|
| 384 |  | 
|---|
| 385 | return TRUE; | 
|---|
| 386 | } | 
|---|
| 387 |  | 
|---|
| 388 |  | 
|---|
| 389 | /* Handle an i370 specific section when reading an object file.  This | 
|---|
| 390 | is called when elfcode.h finds a section with an unknown type.  */ | 
|---|
| 391 | /* XXX hack alert bogus This routine is mostly all junk and almost | 
|---|
| 392 | * certainly does the wrong thing.  Its here simply because it does | 
|---|
| 393 | * just enough to allow glibc-2.1 ld.so to compile & link. | 
|---|
| 394 | */ | 
|---|
| 395 |  | 
|---|
| 396 | static bfd_boolean | 
|---|
| 397 | i370_elf_section_from_shdr (abfd, hdr, name) | 
|---|
| 398 | bfd *abfd; | 
|---|
| 399 | Elf_Internal_Shdr *hdr; | 
|---|
| 400 | const char *name; | 
|---|
| 401 | { | 
|---|
| 402 | asection *newsect; | 
|---|
| 403 | flagword flags; | 
|---|
| 404 |  | 
|---|
| 405 | if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name)) | 
|---|
| 406 | return FALSE; | 
|---|
| 407 |  | 
|---|
| 408 | newsect = hdr->bfd_section; | 
|---|
| 409 | flags = bfd_get_section_flags (abfd, newsect); | 
|---|
| 410 | if (hdr->sh_flags & SHF_EXCLUDE) | 
|---|
| 411 | flags |= SEC_EXCLUDE; | 
|---|
| 412 |  | 
|---|
| 413 | if (hdr->sh_type == SHT_ORDERED) | 
|---|
| 414 | flags |= SEC_SORT_ENTRIES; | 
|---|
| 415 |  | 
|---|
| 416 | bfd_set_section_flags (abfd, newsect, flags); | 
|---|
| 417 | return TRUE; | 
|---|
| 418 | } | 
|---|
| 419 |  | 
|---|
| 420 |  | 
|---|
| 421 | /* Set up any other section flags and such that may be necessary.  */ | 
|---|
| 422 | /* XXX hack alert bogus This routine is mostly all junk and almost | 
|---|
| 423 | * certainly does the wrong thing.  Its here simply because it does | 
|---|
| 424 | * just enough to allow glibc-2.1 ld.so to compile & link. | 
|---|
| 425 | */ | 
|---|
| 426 |  | 
|---|
| 427 | static bfd_boolean | 
|---|
| 428 | i370_elf_fake_sections (abfd, shdr, asect) | 
|---|
| 429 | bfd *abfd ATTRIBUTE_UNUSED; | 
|---|
| 430 | Elf_Internal_Shdr *shdr; | 
|---|
| 431 | asection *asect; | 
|---|
| 432 | { | 
|---|
| 433 | if ((asect->flags & SEC_EXCLUDE) != 0) | 
|---|
| 434 | shdr->sh_flags |= SHF_EXCLUDE; | 
|---|
| 435 |  | 
|---|
| 436 | if ((asect->flags & SEC_SORT_ENTRIES) != 0) | 
|---|
| 437 | shdr->sh_type = SHT_ORDERED; | 
|---|
| 438 |  | 
|---|
| 439 | return TRUE; | 
|---|
| 440 | } | 
|---|
| 441 |  | 
|---|
| 442 |  | 
|---|
| 443 | #if 0 | 
|---|
| 444 | /* Create a special linker section */ | 
|---|
| 445 | /* XXX hack alert bogus This routine is mostly all junk and almost | 
|---|
| 446 | * certainly does the wrong thing.  Its here simply because it does | 
|---|
| 447 | * just enough to allow glibc-2.1 ld.so to compile & link. | 
|---|
| 448 | */ | 
|---|
| 449 |  | 
|---|
| 450 | static elf_linker_section_t * | 
|---|
| 451 | i370_elf_create_linker_section (abfd, info, which) | 
|---|
| 452 | bfd *abfd; | 
|---|
| 453 | struct bfd_link_info *info; | 
|---|
| 454 | enum elf_linker_section_enum which; | 
|---|
| 455 | { | 
|---|
| 456 | bfd *dynobj = elf_hash_table (info)->dynobj; | 
|---|
| 457 | elf_linker_section_t *lsect; | 
|---|
| 458 |  | 
|---|
| 459 | /* Record the first bfd section that needs the special section */ | 
|---|
| 460 | if (!dynobj) | 
|---|
| 461 | dynobj = elf_hash_table (info)->dynobj = abfd; | 
|---|
| 462 |  | 
|---|
| 463 | /* If this is the first time, create the section */ | 
|---|
| 464 | lsect = elf_linker_section (dynobj, which); | 
|---|
| 465 | if (!lsect) | 
|---|
| 466 | { | 
|---|
| 467 | elf_linker_section_t defaults; | 
|---|
| 468 | static elf_linker_section_t zero_section; | 
|---|
| 469 |  | 
|---|
| 470 | defaults = zero_section; | 
|---|
| 471 | defaults.which = which; | 
|---|
| 472 | defaults.hole_written_p = FALSE; | 
|---|
| 473 | defaults.alignment = 2; | 
|---|
| 474 |  | 
|---|
| 475 | /* Both of these sections are (technically) created by the user | 
|---|
| 476 | putting data in them, so they shouldn't be marked | 
|---|
| 477 | SEC_LINKER_CREATED. | 
|---|
| 478 |  | 
|---|
| 479 | The linker creates them so it has somewhere to attach their | 
|---|
| 480 | respective symbols. In fact, if they were empty it would | 
|---|
| 481 | be OK to leave the symbol set to 0 (or any random number), because | 
|---|
| 482 | the appropriate register should never be used.  */ | 
|---|
| 483 | defaults.flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | 
|---|
| 484 | | SEC_IN_MEMORY); | 
|---|
| 485 |  | 
|---|
| 486 | switch (which) | 
|---|
| 487 | { | 
|---|
| 488 | default: | 
|---|
| 489 | (*_bfd_error_handler) ("%s: Unknown special linker type %d", | 
|---|
| 490 | bfd_archive_filename (abfd), | 
|---|
| 491 | (int) which); | 
|---|
| 492 |  | 
|---|
| 493 | bfd_set_error (bfd_error_bad_value); | 
|---|
| 494 | return (elf_linker_section_t *)0; | 
|---|
| 495 |  | 
|---|
| 496 | case LINKER_SECTION_SDATA:      /* .sdata/.sbss section */ | 
|---|
| 497 | defaults.name           = ".sdata"; | 
|---|
| 498 | defaults.rel_name       = ".rela.sdata"; | 
|---|
| 499 | defaults.bss_name       = ".sbss"; | 
|---|
| 500 | defaults.sym_name       = "_SDA_BASE_"; | 
|---|
| 501 | defaults.sym_offset     = 32768; | 
|---|
| 502 | break; | 
|---|
| 503 |  | 
|---|
| 504 | case LINKER_SECTION_SDATA2:     /* .sdata2/.sbss2 section */ | 
|---|
| 505 | defaults.name           = ".sdata2"; | 
|---|
| 506 | defaults.rel_name       = ".rela.sdata2"; | 
|---|
| 507 | defaults.bss_name       = ".sbss2"; | 
|---|
| 508 | defaults.sym_name       = "_SDA2_BASE_"; | 
|---|
| 509 | defaults.sym_offset     = 32768; | 
|---|
| 510 | defaults.flags         |= SEC_READONLY; | 
|---|
| 511 | break; | 
|---|
| 512 | } | 
|---|
| 513 |  | 
|---|
| 514 | lsect = _bfd_elf_create_linker_section (abfd, info, which, &defaults); | 
|---|
| 515 | } | 
|---|
| 516 |  | 
|---|
| 517 | return lsect; | 
|---|
| 518 | } | 
|---|
| 519 | #endif | 
|---|
| 520 |  | 
|---|
| 521 |  | 
|---|
| 522 | /* We have to create .dynsbss and .rela.sbss here so that they get mapped | 
|---|
| 523 | to output sections (just like _bfd_elf_create_dynamic_sections has | 
|---|
| 524 | to create .dynbss and .rela.bss).  */ | 
|---|
| 525 | /* XXX hack alert bogus This routine is mostly all junk and almost | 
|---|
| 526 | * certainly does the wrong thing.  Its here simply because it does | 
|---|
| 527 | * just enough to allow glibc-2.1 ld.so to compile & link. | 
|---|
| 528 | */ | 
|---|
| 529 |  | 
|---|
| 530 | static bfd_boolean | 
|---|
| 531 | i370_elf_create_dynamic_sections (abfd, info) | 
|---|
| 532 | bfd *abfd; | 
|---|
| 533 | struct bfd_link_info *info; | 
|---|
| 534 | { | 
|---|
| 535 | register asection *s; | 
|---|
| 536 | flagword flags; | 
|---|
| 537 |  | 
|---|
| 538 | if (!_bfd_elf_create_dynamic_sections(abfd, info)) | 
|---|
| 539 | return FALSE; | 
|---|
| 540 |  | 
|---|
| 541 | flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY | 
|---|
| 542 | | SEC_LINKER_CREATED); | 
|---|
| 543 |  | 
|---|
| 544 | s = bfd_make_section (abfd, ".dynsbss"); | 
|---|
| 545 | if (s == NULL | 
|---|
| 546 | || ! bfd_set_section_flags (abfd, s, SEC_ALLOC)) | 
|---|
| 547 | return FALSE; | 
|---|
| 548 |  | 
|---|
| 549 | if (! info->shared) | 
|---|
| 550 | { | 
|---|
| 551 | s = bfd_make_section (abfd, ".rela.sbss"); | 
|---|
| 552 | if (s == NULL | 
|---|
| 553 | || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY) | 
|---|
| 554 | || ! bfd_set_section_alignment (abfd, s, 2)) | 
|---|
| 555 | return FALSE; | 
|---|
| 556 | } | 
|---|
| 557 |  | 
|---|
| 558 | /* xxx beats me, seem to need a rela.text ...  */ | 
|---|
| 559 | s = bfd_make_section (abfd, ".rela.text"); | 
|---|
| 560 | if (s == NULL | 
|---|
| 561 | || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY) | 
|---|
| 562 | || ! bfd_set_section_alignment (abfd, s, 2)) | 
|---|
| 563 | return FALSE; | 
|---|
| 564 | return TRUE; | 
|---|
| 565 | } | 
|---|
| 566 |  | 
|---|
| 567 | /* Adjust a symbol defined by a dynamic object and referenced by a | 
|---|
| 568 | regular object.  The current definition is in some section of the | 
|---|
| 569 | dynamic object, but we're not including those sections.  We have to | 
|---|
| 570 | change the definition to something the rest of the link can | 
|---|
| 571 | understand.  */ | 
|---|
| 572 | /* XXX hack alert bogus This routine is mostly all junk and almost | 
|---|
| 573 | * certainly does the wrong thing.  Its here simply because it does | 
|---|
| 574 | * just enough to allow glibc-2.1 ld.so to compile & link. | 
|---|
| 575 | */ | 
|---|
| 576 |  | 
|---|
| 577 | static bfd_boolean | 
|---|
| 578 | i370_elf_adjust_dynamic_symbol (info, h) | 
|---|
| 579 | struct bfd_link_info *info; | 
|---|
| 580 | struct elf_link_hash_entry *h; | 
|---|
| 581 | { | 
|---|
| 582 | bfd *dynobj = elf_hash_table (info)->dynobj; | 
|---|
| 583 | asection *s; | 
|---|
| 584 | unsigned int power_of_two; | 
|---|
| 585 |  | 
|---|
| 586 | #ifdef DEBUG | 
|---|
| 587 | fprintf (stderr, "i370_elf_adjust_dynamic_symbol called for %s\n", | 
|---|
| 588 | h->root.root.string); | 
|---|
| 589 | #endif | 
|---|
| 590 |  | 
|---|
| 591 | /* Make sure we know what is going on here.  */ | 
|---|
| 592 | BFD_ASSERT (dynobj != NULL | 
|---|
| 593 | && ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) | 
|---|
| 594 | || h->weakdef != NULL | 
|---|
| 595 | || ((h->elf_link_hash_flags | 
|---|
| 596 | & ELF_LINK_HASH_DEF_DYNAMIC) != 0 | 
|---|
| 597 | && (h->elf_link_hash_flags | 
|---|
| 598 | & ELF_LINK_HASH_REF_REGULAR) != 0 | 
|---|
| 599 | && (h->elf_link_hash_flags | 
|---|
| 600 | & ELF_LINK_HASH_DEF_REGULAR) == 0))); | 
|---|
| 601 |  | 
|---|
| 602 | s = bfd_get_section_by_name (dynobj, ".rela.text"); | 
|---|
| 603 | BFD_ASSERT (s != NULL); | 
|---|
| 604 | s->_raw_size += sizeof (Elf32_External_Rela); | 
|---|
| 605 |  | 
|---|
| 606 | /* If this is a weak symbol, and there is a real definition, the | 
|---|
| 607 | processor independent code will have arranged for us to see the | 
|---|
| 608 | real definition first, and we can just use the same value.  */ | 
|---|
| 609 | if (h->weakdef != NULL) | 
|---|
| 610 | { | 
|---|
| 611 | BFD_ASSERT (h->weakdef->root.type == bfd_link_hash_defined | 
|---|
| 612 | || h->weakdef->root.type == bfd_link_hash_defweak); | 
|---|
| 613 | h->root.u.def.section = h->weakdef->root.u.def.section; | 
|---|
| 614 | h->root.u.def.value = h->weakdef->root.u.def.value; | 
|---|
| 615 | return TRUE; | 
|---|
| 616 | } | 
|---|
| 617 |  | 
|---|
| 618 | /* This is a reference to a symbol defined by a dynamic object which | 
|---|
| 619 | is not a function.  */ | 
|---|
| 620 |  | 
|---|
| 621 | /* If we are creating a shared library, we must presume that the | 
|---|
| 622 | only references to the symbol are via the global offset table. | 
|---|
| 623 | For such cases we need not do anything here; the relocations will | 
|---|
| 624 | be handled correctly by relocate_section.  */ | 
|---|
| 625 | if (info->shared) | 
|---|
| 626 | return TRUE; | 
|---|
| 627 |  | 
|---|
| 628 | /* We must allocate the symbol in our .dynbss section, which will | 
|---|
| 629 | become part of the .bss section of the executable.  There will be | 
|---|
| 630 | an entry for this symbol in the .dynsym section.  The dynamic | 
|---|
| 631 | object will contain position independent code, so all references | 
|---|
| 632 | from the dynamic object to this symbol will go through the global | 
|---|
| 633 | offset table.  The dynamic linker will use the .dynsym entry to | 
|---|
| 634 | determine the address it must put in the global offset table, so | 
|---|
| 635 | both the dynamic object and the regular object will refer to the | 
|---|
| 636 | same memory location for the variable. | 
|---|
| 637 |  | 
|---|
| 638 | Of course, if the symbol is sufficiently small, we must instead | 
|---|
| 639 | allocate it in .sbss.  FIXME: It would be better to do this if and | 
|---|
| 640 | only if there were actually SDAREL relocs for that symbol.  */ | 
|---|
| 641 |  | 
|---|
| 642 | if (h->size <= elf_gp_size (dynobj)) | 
|---|
| 643 | s = bfd_get_section_by_name (dynobj, ".dynsbss"); | 
|---|
| 644 | else | 
|---|
| 645 | s = bfd_get_section_by_name (dynobj, ".dynbss"); | 
|---|
| 646 | BFD_ASSERT (s != NULL); | 
|---|
| 647 |  | 
|---|
| 648 | /* We must generate a R_I370_COPY reloc to tell the dynamic linker to | 
|---|
| 649 | copy the initial value out of the dynamic object and into the | 
|---|
| 650 | runtime process image.  We need to remember the offset into the | 
|---|
| 651 | .rela.bss section we are going to use.  */ | 
|---|
| 652 | if ((h->root.u.def.section->flags & SEC_ALLOC) != 0) | 
|---|
| 653 | { | 
|---|
| 654 | asection *srel; | 
|---|
| 655 |  | 
|---|
| 656 | if (h->size <= elf_gp_size (dynobj)) | 
|---|
| 657 | srel = bfd_get_section_by_name (dynobj, ".rela.sbss"); | 
|---|
| 658 | else | 
|---|
| 659 | srel = bfd_get_section_by_name (dynobj, ".rela.bss"); | 
|---|
| 660 | BFD_ASSERT (srel != NULL); | 
|---|
| 661 | srel->_raw_size += sizeof (Elf32_External_Rela); | 
|---|
| 662 | h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY; | 
|---|
| 663 | } | 
|---|
| 664 |  | 
|---|
| 665 | /* We need to figure out the alignment required for this symbol.  I | 
|---|
| 666 | have no idea how ELF linkers handle this.  */ | 
|---|
| 667 | power_of_two = bfd_log2 (h->size); | 
|---|
| 668 | if (power_of_two > 4) | 
|---|
| 669 | power_of_two = 4; | 
|---|
| 670 |  | 
|---|
| 671 | /* Apply the required alignment.  */ | 
|---|
| 672 | s->_raw_size = BFD_ALIGN (s->_raw_size, | 
|---|
| 673 | (bfd_size_type) (1 << power_of_two)); | 
|---|
| 674 | if (power_of_two > bfd_get_section_alignment (dynobj, s)) | 
|---|
| 675 | { | 
|---|
| 676 | if (! bfd_set_section_alignment (dynobj, s, power_of_two)) | 
|---|
| 677 | return FALSE; | 
|---|
| 678 | } | 
|---|
| 679 |  | 
|---|
| 680 | /* Define the symbol as being at this point in the section.  */ | 
|---|
| 681 | h->root.u.def.section = s; | 
|---|
| 682 | h->root.u.def.value = s->_raw_size; | 
|---|
| 683 |  | 
|---|
| 684 | /* Increment the section size to make room for the symbol.  */ | 
|---|
| 685 | s->_raw_size += h->size; | 
|---|
| 686 |  | 
|---|
| 687 | return TRUE; | 
|---|
| 688 | } | 
|---|
| 689 |  | 
|---|
| 690 |  | 
|---|
| 691 | /* Increment the index of a dynamic symbol by a given amount.  Called | 
|---|
| 692 | via elf_link_hash_traverse.  */ | 
|---|
| 693 | /* XXX hack alert bogus This routine is mostly all junk and almost | 
|---|
| 694 | * certainly does the wrong thing.  Its here simply because it does | 
|---|
| 695 | * just enough to allow glibc-2.1 ld.so to compile & link. | 
|---|
| 696 | */ | 
|---|
| 697 |  | 
|---|
| 698 | static bfd_boolean | 
|---|
| 699 | i370_elf_adjust_dynindx (h, cparg) | 
|---|
| 700 | struct elf_link_hash_entry *h; | 
|---|
| 701 | PTR cparg; | 
|---|
| 702 | { | 
|---|
| 703 | int *cp = (int *) cparg; | 
|---|
| 704 |  | 
|---|
| 705 | #ifdef DEBUG | 
|---|
| 706 | fprintf (stderr, | 
|---|
| 707 | "i370_elf_adjust_dynindx called, h->dynindx = %d, *cp = %d\n", | 
|---|
| 708 | h->dynindx, *cp); | 
|---|
| 709 | #endif | 
|---|
| 710 |  | 
|---|
| 711 | if (h->root.type == bfd_link_hash_warning) | 
|---|
| 712 | h = (struct elf_link_hash_entry *) h->root.u.i.link; | 
|---|
| 713 |  | 
|---|
| 714 | if (h->dynindx != -1) | 
|---|
| 715 | h->dynindx += *cp; | 
|---|
| 716 |  | 
|---|
| 717 | return TRUE; | 
|---|
| 718 | } | 
|---|
| 719 |  | 
|---|
| 720 |  | 
|---|
| 721 | /* Set the sizes of the dynamic sections.  */ | 
|---|
| 722 | /* XXX hack alert bogus This routine is mostly all junk and almost | 
|---|
| 723 | * certainly does the wrong thing.  Its here simply because it does | 
|---|
| 724 | * just enough to allow glibc-2.1 ld.so to compile & link. | 
|---|
| 725 | */ | 
|---|
| 726 |  | 
|---|
| 727 | static bfd_boolean | 
|---|
| 728 | i370_elf_size_dynamic_sections (output_bfd, info) | 
|---|
| 729 | bfd *output_bfd; | 
|---|
| 730 | struct bfd_link_info *info; | 
|---|
| 731 | { | 
|---|
| 732 | bfd *dynobj; | 
|---|
| 733 | asection *s; | 
|---|
| 734 | bfd_boolean plt; | 
|---|
| 735 | bfd_boolean relocs; | 
|---|
| 736 | bfd_boolean reltext; | 
|---|
| 737 |  | 
|---|
| 738 | #ifdef DEBUG | 
|---|
| 739 | fprintf (stderr, "i370_elf_size_dynamic_sections called\n"); | 
|---|
| 740 | #endif | 
|---|
| 741 |  | 
|---|
| 742 | dynobj = elf_hash_table (info)->dynobj; | 
|---|
| 743 | BFD_ASSERT (dynobj != NULL); | 
|---|
| 744 |  | 
|---|
| 745 | if (elf_hash_table (info)->dynamic_sections_created) | 
|---|
| 746 | { | 
|---|
| 747 | /* Set the contents of the .interp section to the interpreter.  */ | 
|---|
| 748 | if (! info->shared) | 
|---|
| 749 | { | 
|---|
| 750 | s = bfd_get_section_by_name (dynobj, ".interp"); | 
|---|
| 751 | BFD_ASSERT (s != NULL); | 
|---|
| 752 | s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER; | 
|---|
| 753 | s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER; | 
|---|
| 754 | } | 
|---|
| 755 | } | 
|---|
| 756 | else | 
|---|
| 757 | { | 
|---|
| 758 | /* We may have created entries in the .rela.got, .rela.sdata, and | 
|---|
| 759 | .rela.sdata2 sections.  However, if we are not creating the | 
|---|
| 760 | dynamic sections, we will not actually use these entries.  Reset | 
|---|
| 761 | the size of .rela.got, et al, which will cause it to get | 
|---|
| 762 | stripped from the output file below.  */ | 
|---|
| 763 | static char *rela_sections[] = { ".rela.got", ".rela.sdata", | 
|---|
| 764 | ".rela.sdata2", ".rela.sbss", | 
|---|
| 765 | (char *)0 }; | 
|---|
| 766 | char **p; | 
|---|
| 767 |  | 
|---|
| 768 | for (p = rela_sections; *p != (char *)0; p++) | 
|---|
| 769 | { | 
|---|
| 770 | s = bfd_get_section_by_name (dynobj, *p); | 
|---|
| 771 | if (s != NULL) | 
|---|
| 772 | s->_raw_size = 0; | 
|---|
| 773 | } | 
|---|
| 774 | } | 
|---|
| 775 |  | 
|---|
| 776 | /* The check_relocs and adjust_dynamic_symbol entry points have | 
|---|
| 777 | determined the sizes of the various dynamic sections.  Allocate | 
|---|
| 778 | memory for them.  */ | 
|---|
| 779 | plt = FALSE; | 
|---|
| 780 | relocs = FALSE; | 
|---|
| 781 | reltext = FALSE; | 
|---|
| 782 | for (s = dynobj->sections; s != NULL; s = s->next) | 
|---|
| 783 | { | 
|---|
| 784 | const char *name; | 
|---|
| 785 | bfd_boolean strip; | 
|---|
| 786 |  | 
|---|
| 787 | if ((s->flags & SEC_LINKER_CREATED) == 0) | 
|---|
| 788 | continue; | 
|---|
| 789 |  | 
|---|
| 790 | /* It's OK to base decisions on the section name, because none | 
|---|
| 791 | of the dynobj section names depend upon the input files.  */ | 
|---|
| 792 | name = bfd_get_section_name (dynobj, s); | 
|---|
| 793 | strip = FALSE; | 
|---|
| 794 |  | 
|---|
| 795 | if (strcmp (name, ".plt") == 0) | 
|---|
| 796 | { | 
|---|
| 797 | if (s->_raw_size == 0) | 
|---|
| 798 | { | 
|---|
| 799 | /* Strip this section if we don't need it; see the | 
|---|
| 800 | comment below.  */ | 
|---|
| 801 | strip = TRUE; | 
|---|
| 802 | } | 
|---|
| 803 | else | 
|---|
| 804 | { | 
|---|
| 805 | /* Remember whether there is a PLT.  */ | 
|---|
| 806 | plt = TRUE; | 
|---|
| 807 | } | 
|---|
| 808 | } | 
|---|
| 809 | else if (strncmp (name, ".rela", 5) == 0) | 
|---|
| 810 | { | 
|---|
| 811 | if (s->_raw_size == 0) | 
|---|
| 812 | { | 
|---|
| 813 | /* If we don't need this section, strip it from the | 
|---|
| 814 | output file.  This is mostly to handle .rela.bss and | 
|---|
| 815 | .rela.plt.  We must create both sections in | 
|---|
| 816 | create_dynamic_sections, because they must be created | 
|---|
| 817 | before the linker maps input sections to output | 
|---|
| 818 | sections.  The linker does that before | 
|---|
| 819 | adjust_dynamic_symbol is called, and it is that | 
|---|
| 820 | function which decides whether anything needs to go | 
|---|
| 821 | into these sections.  */ | 
|---|
| 822 | strip = TRUE; | 
|---|
| 823 | } | 
|---|
| 824 | else | 
|---|
| 825 | { | 
|---|
| 826 | asection *target; | 
|---|
| 827 | const char *outname; | 
|---|
| 828 |  | 
|---|
| 829 | /* Remember whether there are any relocation sections.  */ | 
|---|
| 830 | relocs = TRUE; | 
|---|
| 831 |  | 
|---|
| 832 | /* If this relocation section applies to a read only | 
|---|
| 833 | section, then we probably need a DT_TEXTREL entry.  */ | 
|---|
| 834 | outname = bfd_get_section_name (output_bfd, | 
|---|
| 835 | s->output_section); | 
|---|
| 836 | target = bfd_get_section_by_name (output_bfd, outname + 5); | 
|---|
| 837 | if (target != NULL | 
|---|
| 838 | && (target->flags & SEC_READONLY) != 0 | 
|---|
| 839 | && (target->flags & SEC_ALLOC) != 0) | 
|---|
| 840 | reltext = TRUE; | 
|---|
| 841 |  | 
|---|
| 842 | /* We use the reloc_count field as a counter if we need | 
|---|
| 843 | to copy relocs into the output file.  */ | 
|---|
| 844 | s->reloc_count = 0; | 
|---|
| 845 | } | 
|---|
| 846 | } | 
|---|
| 847 | else if (strcmp (name, ".got") != 0 | 
|---|
| 848 | && strcmp (name, ".sdata") != 0 | 
|---|
| 849 | && strcmp (name, ".sdata2") != 0) | 
|---|
| 850 | { | 
|---|
| 851 | /* It's not one of our sections, so don't allocate space.  */ | 
|---|
| 852 | continue; | 
|---|
| 853 | } | 
|---|
| 854 |  | 
|---|
| 855 | if (strip) | 
|---|
| 856 | { | 
|---|
| 857 | asection **spp; | 
|---|
| 858 |  | 
|---|
| 859 | for (spp = &s->output_section->owner->sections; | 
|---|
| 860 | *spp != NULL; | 
|---|
| 861 | spp = &(*spp)->next) | 
|---|
| 862 | { | 
|---|
| 863 | if (*spp == s->output_section) | 
|---|
| 864 | { | 
|---|
| 865 | bfd_section_list_remove (s->output_section->owner, spp); | 
|---|
| 866 | --s->output_section->owner->section_count; | 
|---|
| 867 | break; | 
|---|
| 868 | } | 
|---|
| 869 | } | 
|---|
| 870 | continue; | 
|---|
| 871 | } | 
|---|
| 872 | /* Allocate memory for the section contents.  */ | 
|---|
| 873 | s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size); | 
|---|
| 874 | if (s->contents == NULL && s->_raw_size != 0) | 
|---|
| 875 | return FALSE; | 
|---|
| 876 | } | 
|---|
| 877 |  | 
|---|
| 878 | if (elf_hash_table (info)->dynamic_sections_created) | 
|---|
| 879 | { | 
|---|
| 880 | /* Add some entries to the .dynamic section.  We fill in the | 
|---|
| 881 | values later, in i370_elf_finish_dynamic_sections, but we | 
|---|
| 882 | must add the entries now so that we get the correct size for | 
|---|
| 883 | the .dynamic section.  The DT_DEBUG entry is filled in by the | 
|---|
| 884 | dynamic linker and used by the debugger.  */ | 
|---|
| 885 | #define add_dynamic_entry(TAG, VAL) \ | 
|---|
| 886 | bfd_elf32_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL)) | 
|---|
| 887 |  | 
|---|
| 888 | if (!info->shared) | 
|---|
| 889 | { | 
|---|
| 890 | if (!add_dynamic_entry (DT_DEBUG, 0)) | 
|---|
| 891 | return FALSE; | 
|---|
| 892 | } | 
|---|
| 893 |  | 
|---|
| 894 | if (plt) | 
|---|
| 895 | { | 
|---|
| 896 | if (!add_dynamic_entry (DT_PLTGOT, 0) | 
|---|
| 897 | || !add_dynamic_entry (DT_PLTRELSZ, 0) | 
|---|
| 898 | || !add_dynamic_entry (DT_PLTREL, DT_RELA) | 
|---|
| 899 | || !add_dynamic_entry (DT_JMPREL, 0)) | 
|---|
| 900 | return FALSE; | 
|---|
| 901 | } | 
|---|
| 902 |  | 
|---|
| 903 | if (relocs) | 
|---|
| 904 | { | 
|---|
| 905 | if (!add_dynamic_entry (DT_RELA, 0) | 
|---|
| 906 | || !add_dynamic_entry (DT_RELASZ, 0) | 
|---|
| 907 | || !add_dynamic_entry (DT_RELAENT, sizeof (Elf32_External_Rela))) | 
|---|
| 908 | return FALSE; | 
|---|
| 909 | } | 
|---|
| 910 |  | 
|---|
| 911 | if (reltext) | 
|---|
| 912 | { | 
|---|
| 913 | if (!add_dynamic_entry (DT_TEXTREL, 0)) | 
|---|
| 914 | return FALSE; | 
|---|
| 915 | info->flags |= DF_TEXTREL; | 
|---|
| 916 | } | 
|---|
| 917 | } | 
|---|
| 918 | #undef add_dynamic_entry | 
|---|
| 919 |  | 
|---|
| 920 | /* If we are generating a shared library, we generate a section | 
|---|
| 921 | symbol for each output section.  These are local symbols, which | 
|---|
| 922 | means that they must come first in the dynamic symbol table. | 
|---|
| 923 | That means we must increment the dynamic symbol index of every | 
|---|
| 924 | other dynamic symbol. | 
|---|
| 925 |  | 
|---|
| 926 | FIXME: We assume that there will never be relocations to | 
|---|
| 927 | locations in linker-created sections that do not have | 
|---|
| 928 | externally-visible names. Instead, we should work out precisely | 
|---|
| 929 | which sections relocations are targetted at.  */ | 
|---|
| 930 | if (info->shared) | 
|---|
| 931 | { | 
|---|
| 932 | int c; | 
|---|
| 933 |  | 
|---|
| 934 | for (c = 0, s = output_bfd->sections; s != NULL; s = s->next) | 
|---|
| 935 | { | 
|---|
| 936 | if ((s->flags & SEC_LINKER_CREATED) != 0 | 
|---|
| 937 | || (s->flags & SEC_ALLOC) == 0) | 
|---|
| 938 | { | 
|---|
| 939 | elf_section_data (s)->dynindx = -1; | 
|---|
| 940 | continue; | 
|---|
| 941 | } | 
|---|
| 942 |  | 
|---|
| 943 | /* These symbols will have no names, so we don't need to | 
|---|
| 944 | fiddle with dynstr_index.  */ | 
|---|
| 945 |  | 
|---|
| 946 | elf_section_data (s)->dynindx = c + 1; | 
|---|
| 947 |  | 
|---|
| 948 | c++; | 
|---|
| 949 | } | 
|---|
| 950 |  | 
|---|
| 951 | elf_link_hash_traverse (elf_hash_table (info), | 
|---|
| 952 | i370_elf_adjust_dynindx, | 
|---|
| 953 | (PTR) &c); | 
|---|
| 954 | elf_hash_table (info)->dynsymcount += c; | 
|---|
| 955 | } | 
|---|
| 956 |  | 
|---|
| 957 | return TRUE; | 
|---|
| 958 | } | 
|---|
| 959 |  | 
|---|
| 960 |  | 
|---|
| 961 | /* Look through the relocs for a section during the first phase, and | 
|---|
| 962 | allocate space in the global offset table or procedure linkage | 
|---|
| 963 | table.  */ | 
|---|
| 964 | /* XXX hack alert bogus This routine is mostly all junk and almost | 
|---|
| 965 | * certainly does the wrong thing.  Its here simply because it does | 
|---|
| 966 | * just enough to allow glibc-2.1 ld.so to compile & link. | 
|---|
| 967 | */ | 
|---|
| 968 |  | 
|---|
| 969 | static bfd_boolean | 
|---|
| 970 | i370_elf_check_relocs (abfd, info, sec, relocs) | 
|---|
| 971 | bfd *abfd; | 
|---|
| 972 | struct bfd_link_info *info; | 
|---|
| 973 | asection *sec; | 
|---|
| 974 | const Elf_Internal_Rela *relocs; | 
|---|
| 975 | { | 
|---|
| 976 | bfd *dynobj; | 
|---|
| 977 | Elf_Internal_Shdr *symtab_hdr; | 
|---|
| 978 | struct elf_link_hash_entry **sym_hashes; | 
|---|
| 979 | const Elf_Internal_Rela *rel; | 
|---|
| 980 | const Elf_Internal_Rela *rel_end; | 
|---|
| 981 | bfd_vma *local_got_offsets; | 
|---|
| 982 | asection *sreloc; | 
|---|
| 983 |  | 
|---|
| 984 | if (info->relocateable) | 
|---|
| 985 | return TRUE; | 
|---|
| 986 |  | 
|---|
| 987 | #ifdef DEBUG | 
|---|
| 988 | fprintf (stderr, "i370_elf_check_relocs called for section %s in %s\n", | 
|---|
| 989 | bfd_get_section_name (abfd, sec), | 
|---|
| 990 | bfd_archive_filename (abfd)); | 
|---|
| 991 | #endif | 
|---|
| 992 |  | 
|---|
| 993 | dynobj = elf_hash_table (info)->dynobj; | 
|---|
| 994 | symtab_hdr = &elf_tdata (abfd)->symtab_hdr; | 
|---|
| 995 | sym_hashes = elf_sym_hashes (abfd); | 
|---|
| 996 | local_got_offsets = elf_local_got_offsets (abfd); | 
|---|
| 997 |  | 
|---|
| 998 | sreloc = NULL; | 
|---|
| 999 |  | 
|---|
| 1000 | rel_end = relocs + sec->reloc_count; | 
|---|
| 1001 | for (rel = relocs; rel < rel_end; rel++) | 
|---|
| 1002 | { | 
|---|
| 1003 | unsigned long r_symndx; | 
|---|
| 1004 | struct elf_link_hash_entry *h; | 
|---|
| 1005 |  | 
|---|
| 1006 | r_symndx = ELF32_R_SYM (rel->r_info); | 
|---|
| 1007 | if (r_symndx < symtab_hdr->sh_info) | 
|---|
| 1008 | h = NULL; | 
|---|
| 1009 | else | 
|---|
| 1010 | h = sym_hashes[r_symndx - symtab_hdr->sh_info]; | 
|---|
| 1011 |  | 
|---|
| 1012 | if (info->shared) | 
|---|
| 1013 | { | 
|---|
| 1014 | #ifdef DEBUG | 
|---|
| 1015 | fprintf (stderr, | 
|---|
| 1016 | "i370_elf_check_relocs needs to create relocation for %s\n", | 
|---|
| 1017 | (h && h->root.root.string) | 
|---|
| 1018 | ? h->root.root.string : "<unknown>"); | 
|---|
| 1019 | #endif | 
|---|
| 1020 | if (sreloc == NULL) | 
|---|
| 1021 | { | 
|---|
| 1022 | const char *name; | 
|---|
| 1023 |  | 
|---|
| 1024 | name = (bfd_elf_string_from_elf_section | 
|---|
| 1025 | (abfd, | 
|---|
| 1026 | elf_elfheader (abfd)->e_shstrndx, | 
|---|
| 1027 | elf_section_data (sec)->rel_hdr.sh_name)); | 
|---|
| 1028 | if (name == NULL) | 
|---|
| 1029 | return FALSE; | 
|---|
| 1030 |  | 
|---|
| 1031 | BFD_ASSERT (strncmp (name, ".rela", 5) == 0 | 
|---|
| 1032 | && strcmp (bfd_get_section_name (abfd, sec), name + 5) == 0); | 
|---|
| 1033 |  | 
|---|
| 1034 | sreloc = bfd_get_section_by_name (dynobj, name); | 
|---|
| 1035 | if (sreloc == NULL) | 
|---|
| 1036 | { | 
|---|
| 1037 | flagword flags; | 
|---|
| 1038 |  | 
|---|
| 1039 | sreloc = bfd_make_section (dynobj, name); | 
|---|
| 1040 | flags = (SEC_HAS_CONTENTS | SEC_READONLY | 
|---|
| 1041 | | SEC_IN_MEMORY | SEC_LINKER_CREATED); | 
|---|
| 1042 | if ((sec->flags & SEC_ALLOC) != 0) | 
|---|
| 1043 | flags |= SEC_ALLOC | SEC_LOAD; | 
|---|
| 1044 | if (sreloc == NULL | 
|---|
| 1045 | || ! bfd_set_section_flags (dynobj, sreloc, flags) | 
|---|
| 1046 | || ! bfd_set_section_alignment (dynobj, sreloc, 2)) | 
|---|
| 1047 | return FALSE; | 
|---|
| 1048 | } | 
|---|
| 1049 | } | 
|---|
| 1050 |  | 
|---|
| 1051 | sreloc->_raw_size += sizeof (Elf32_External_Rela); | 
|---|
| 1052 |  | 
|---|
| 1053 | /* FIXME: We should here do what the m68k and i386 | 
|---|
| 1054 | backends do: if the reloc is pc-relative, record it | 
|---|
| 1055 | in case it turns out that the reloc is unnecessary | 
|---|
| 1056 | because the symbol is forced local by versioning or | 
|---|
| 1057 | we are linking with -Bdynamic.  Fortunately this | 
|---|
| 1058 | case is not frequent.  */ | 
|---|
| 1059 | } | 
|---|
| 1060 | } | 
|---|
| 1061 |  | 
|---|
| 1062 | return TRUE; | 
|---|
| 1063 | } | 
|---|
| 1064 |  | 
|---|
| 1065 |  | 
|---|
| 1066 | /* Finish up the dynamic sections.  */ | 
|---|
| 1067 | /* XXX hack alert bogus This routine is mostly all junk and almost | 
|---|
| 1068 | * certainly does the wrong thing.  Its here simply because it does | 
|---|
| 1069 | * just enough to allow glibc-2.1 ld.so to compile & link. | 
|---|
| 1070 | */ | 
|---|
| 1071 |  | 
|---|
| 1072 | static bfd_boolean | 
|---|
| 1073 | i370_elf_finish_dynamic_sections (output_bfd, info) | 
|---|
| 1074 | bfd *output_bfd; | 
|---|
| 1075 | struct bfd_link_info *info; | 
|---|
| 1076 | { | 
|---|
| 1077 | asection *sdyn; | 
|---|
| 1078 | bfd *dynobj = elf_hash_table (info)->dynobj; | 
|---|
| 1079 | asection *sgot = bfd_get_section_by_name (dynobj, ".got"); | 
|---|
| 1080 |  | 
|---|
| 1081 | #ifdef DEBUG | 
|---|
| 1082 | fprintf (stderr, "i370_elf_finish_dynamic_sections called\n"); | 
|---|
| 1083 | #endif | 
|---|
| 1084 |  | 
|---|
| 1085 | sdyn = bfd_get_section_by_name (dynobj, ".dynamic"); | 
|---|
| 1086 |  | 
|---|
| 1087 | if (elf_hash_table (info)->dynamic_sections_created) | 
|---|
| 1088 | { | 
|---|
| 1089 | asection *splt; | 
|---|
| 1090 | Elf32_External_Dyn *dyncon, *dynconend; | 
|---|
| 1091 |  | 
|---|
| 1092 | splt = bfd_get_section_by_name (dynobj, ".plt"); | 
|---|
| 1093 | BFD_ASSERT (splt != NULL && sdyn != NULL); | 
|---|
| 1094 |  | 
|---|
| 1095 | dyncon = (Elf32_External_Dyn *) sdyn->contents; | 
|---|
| 1096 | dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->_raw_size); | 
|---|
| 1097 | for (; dyncon < dynconend; dyncon++) | 
|---|
| 1098 | { | 
|---|
| 1099 | Elf_Internal_Dyn dyn; | 
|---|
| 1100 | const char *name; | 
|---|
| 1101 | bfd_boolean size; | 
|---|
| 1102 |  | 
|---|
| 1103 | bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn); | 
|---|
| 1104 |  | 
|---|
| 1105 | switch (dyn.d_tag) | 
|---|
| 1106 | { | 
|---|
| 1107 | case DT_PLTGOT:   name = ".plt";      size = FALSE; break; | 
|---|
| 1108 | case DT_PLTRELSZ: name = ".rela.plt"; size = TRUE;  break; | 
|---|
| 1109 | case DT_JMPREL:   name = ".rela.plt"; size = FALSE; break; | 
|---|
| 1110 | default:          name = NULL;        size = FALSE; break; | 
|---|
| 1111 | } | 
|---|
| 1112 |  | 
|---|
| 1113 | if (name != NULL) | 
|---|
| 1114 | { | 
|---|
| 1115 | asection *s; | 
|---|
| 1116 |  | 
|---|
| 1117 | s = bfd_get_section_by_name (output_bfd, name); | 
|---|
| 1118 | if (s == NULL) | 
|---|
| 1119 | dyn.d_un.d_val = 0; | 
|---|
| 1120 | else | 
|---|
| 1121 | { | 
|---|
| 1122 | if (! size) | 
|---|
| 1123 | dyn.d_un.d_ptr = s->vma; | 
|---|
| 1124 | else | 
|---|
| 1125 | { | 
|---|
| 1126 | if (s->_cooked_size != 0) | 
|---|
| 1127 | dyn.d_un.d_val = s->_cooked_size; | 
|---|
| 1128 | else | 
|---|
| 1129 | dyn.d_un.d_val = s->_raw_size; | 
|---|
| 1130 | } | 
|---|
| 1131 | } | 
|---|
| 1132 | bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); | 
|---|
| 1133 | } | 
|---|
| 1134 | } | 
|---|
| 1135 | } | 
|---|
| 1136 |  | 
|---|
| 1137 | /* Add a blrl instruction at _GLOBAL_OFFSET_TABLE_-4 so that a function can | 
|---|
| 1138 | easily find the address of the _GLOBAL_OFFSET_TABLE_.  */ | 
|---|
| 1139 | /* XXX this is clearly very wrong for the 370 arch */ | 
|---|
| 1140 | if (sgot) | 
|---|
| 1141 | { | 
|---|
| 1142 | unsigned char *contents = sgot->contents; | 
|---|
| 1143 | bfd_put_32 (output_bfd, (bfd_vma) 0x4e800021 /* blrl */, contents); | 
|---|
| 1144 |  | 
|---|
| 1145 | if (sdyn == NULL) | 
|---|
| 1146 | bfd_put_32 (output_bfd, (bfd_vma) 0, contents+4); | 
|---|
| 1147 | else | 
|---|
| 1148 | bfd_put_32 (output_bfd, | 
|---|
| 1149 | sdyn->output_section->vma + sdyn->output_offset, | 
|---|
| 1150 | contents+4); | 
|---|
| 1151 |  | 
|---|
| 1152 | elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4; | 
|---|
| 1153 | } | 
|---|
| 1154 |  | 
|---|
| 1155 | if (info->shared) | 
|---|
| 1156 | { | 
|---|
| 1157 | asection *sdynsym; | 
|---|
| 1158 | asection *s; | 
|---|
| 1159 | Elf_Internal_Sym sym; | 
|---|
| 1160 | int maxdindx = 0; | 
|---|
| 1161 |  | 
|---|
| 1162 | /* Set up the section symbols for the output sections.  */ | 
|---|
| 1163 |  | 
|---|
| 1164 | sdynsym = bfd_get_section_by_name (dynobj, ".dynsym"); | 
|---|
| 1165 | BFD_ASSERT (sdynsym != NULL); | 
|---|
| 1166 |  | 
|---|
| 1167 | sym.st_size = 0; | 
|---|
| 1168 | sym.st_name = 0; | 
|---|
| 1169 | sym.st_info = ELF_ST_INFO (STB_LOCAL, STT_SECTION); | 
|---|
| 1170 | sym.st_other = 0; | 
|---|
| 1171 |  | 
|---|
| 1172 | for (s = output_bfd->sections; s != NULL; s = s->next) | 
|---|
| 1173 | { | 
|---|
| 1174 | int indx, dindx; | 
|---|
| 1175 | Elf32_External_Sym *esym; | 
|---|
| 1176 |  | 
|---|
| 1177 | sym.st_value = s->vma; | 
|---|
| 1178 |  | 
|---|
| 1179 | indx = elf_section_data (s)->this_idx; | 
|---|
| 1180 | dindx = elf_section_data (s)->dynindx; | 
|---|
| 1181 | if (dindx != -1) | 
|---|
| 1182 | { | 
|---|
| 1183 | BFD_ASSERT(indx > 0); | 
|---|
| 1184 | BFD_ASSERT(dindx > 0); | 
|---|
| 1185 |  | 
|---|
| 1186 | if (dindx > maxdindx) | 
|---|
| 1187 | maxdindx = dindx; | 
|---|
| 1188 |  | 
|---|
| 1189 | sym.st_shndx = indx; | 
|---|
| 1190 |  | 
|---|
| 1191 | esym = (Elf32_External_Sym *) sdynsym->contents + dindx; | 
|---|
| 1192 | bfd_elf32_swap_symbol_out (output_bfd, &sym, (PTR) esym, (PTR) 0); | 
|---|
| 1193 | } | 
|---|
| 1194 | } | 
|---|
| 1195 |  | 
|---|
| 1196 | /* Set the sh_info field of the output .dynsym section to the | 
|---|
| 1197 | index of the first global symbol.  */ | 
|---|
| 1198 | elf_section_data (sdynsym->output_section)->this_hdr.sh_info = | 
|---|
| 1199 | maxdindx + 1; | 
|---|
| 1200 | } | 
|---|
| 1201 |  | 
|---|
| 1202 | return TRUE; | 
|---|
| 1203 | } | 
|---|
| 1204 |  | 
|---|
| 1205 |  | 
|---|
| 1206 | /* The RELOCATE_SECTION function is called by the ELF backend linker | 
|---|
| 1207 | to handle the relocations for a section. | 
|---|
| 1208 |  | 
|---|
| 1209 | The relocs are always passed as Rela structures; if the section | 
|---|
| 1210 | actually uses Rel structures, the r_addend field will always be | 
|---|
| 1211 | zero. | 
|---|
| 1212 |  | 
|---|
| 1213 | This function is responsible for adjust the section contents as | 
|---|
| 1214 | necessary, and (if using Rela relocs and generating a | 
|---|
| 1215 | relocateable output file) adjusting the reloc addend as | 
|---|
| 1216 | necessary. | 
|---|
| 1217 |  | 
|---|
| 1218 | This function does not have to worry about setting the reloc | 
|---|
| 1219 | address or the reloc symbol index. | 
|---|
| 1220 |  | 
|---|
| 1221 | LOCAL_SYMS is a pointer to the swapped in local symbols. | 
|---|
| 1222 |  | 
|---|
| 1223 | LOCAL_SECTIONS is an array giving the section in the input file | 
|---|
| 1224 | corresponding to the st_shndx field of each local symbol. | 
|---|
| 1225 |  | 
|---|
| 1226 | The global hash table entry for the global symbols can be found | 
|---|
| 1227 | via elf_sym_hashes (input_bfd). | 
|---|
| 1228 |  | 
|---|
| 1229 | When generating relocateable output, this function must handle | 
|---|
| 1230 | STB_LOCAL/STT_SECTION symbols specially.  The output symbol is | 
|---|
| 1231 | going to be the section symbol corresponding to the output | 
|---|
| 1232 | section, which means that the addend must be adjusted | 
|---|
| 1233 | accordingly.  */ | 
|---|
| 1234 |  | 
|---|
| 1235 | static bfd_boolean | 
|---|
| 1236 | i370_elf_relocate_section (output_bfd, info, input_bfd, input_section, | 
|---|
| 1237 | contents, relocs, local_syms, local_sections) | 
|---|
| 1238 | bfd *output_bfd; | 
|---|
| 1239 | struct bfd_link_info *info; | 
|---|
| 1240 | bfd *input_bfd; | 
|---|
| 1241 | asection *input_section; | 
|---|
| 1242 | bfd_byte *contents; | 
|---|
| 1243 | Elf_Internal_Rela *relocs; | 
|---|
| 1244 | Elf_Internal_Sym *local_syms; | 
|---|
| 1245 | asection **local_sections; | 
|---|
| 1246 | { | 
|---|
| 1247 | Elf_Internal_Shdr *symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; | 
|---|
| 1248 | struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (input_bfd); | 
|---|
| 1249 | bfd *dynobj = elf_hash_table (info)->dynobj; | 
|---|
| 1250 | Elf_Internal_Rela *rel = relocs; | 
|---|
| 1251 | Elf_Internal_Rela *relend = relocs + input_section->reloc_count; | 
|---|
| 1252 | asection *sreloc = NULL; | 
|---|
| 1253 | bfd_vma *local_got_offsets; | 
|---|
| 1254 | bfd_boolean ret = TRUE; | 
|---|
| 1255 |  | 
|---|
| 1256 | if (info->relocateable) | 
|---|
| 1257 | return TRUE; | 
|---|
| 1258 |  | 
|---|
| 1259 | #ifdef DEBUG | 
|---|
| 1260 | fprintf (stderr, "i370_elf_relocate_section called for %s section %s, %ld relocations%s\n", | 
|---|
| 1261 | bfd_archive_filename (input_bfd), | 
|---|
| 1262 | bfd_section_name(input_bfd, input_section), | 
|---|
| 1263 | (long) input_section->reloc_count, | 
|---|
| 1264 | (info->relocateable) ? " (relocatable)" : ""); | 
|---|
| 1265 | #endif | 
|---|
| 1266 |  | 
|---|
| 1267 | if (!i370_elf_howto_table[ R_I370_ADDR31 ])   /* Initialize howto table if needed */ | 
|---|
| 1268 | i370_elf_howto_init (); | 
|---|
| 1269 |  | 
|---|
| 1270 | local_got_offsets = elf_local_got_offsets (input_bfd); | 
|---|
| 1271 |  | 
|---|
| 1272 | for (; rel < relend; rel++) | 
|---|
| 1273 | { | 
|---|
| 1274 | enum i370_reloc_type r_type       = (enum i370_reloc_type)ELF32_R_TYPE (rel->r_info); | 
|---|
| 1275 | bfd_vma offset                    = rel->r_offset; | 
|---|
| 1276 | bfd_vma addend                    = rel->r_addend; | 
|---|
| 1277 | bfd_reloc_status_type r           = bfd_reloc_other; | 
|---|
| 1278 | Elf_Internal_Sym *sym             = (Elf_Internal_Sym *)0; | 
|---|
| 1279 | asection *sec                     = (asection *)0; | 
|---|
| 1280 | struct elf_link_hash_entry *h     = (struct elf_link_hash_entry *)0; | 
|---|
| 1281 | const char *sym_name              = (const char *)0; | 
|---|
| 1282 | reloc_howto_type *howto; | 
|---|
| 1283 | unsigned long r_symndx; | 
|---|
| 1284 | bfd_vma relocation; | 
|---|
| 1285 |  | 
|---|
| 1286 | /* Unknown relocation handling */ | 
|---|
| 1287 | if ((unsigned)r_type >= (unsigned)R_I370_max | 
|---|
| 1288 | || !i370_elf_howto_table[(int)r_type]) | 
|---|
| 1289 | { | 
|---|
| 1290 | (*_bfd_error_handler) ("%s: unknown relocation type %d", | 
|---|
| 1291 | bfd_archive_filename (input_bfd), | 
|---|
| 1292 | (int) r_type); | 
|---|
| 1293 |  | 
|---|
| 1294 | bfd_set_error (bfd_error_bad_value); | 
|---|
| 1295 | ret = FALSE; | 
|---|
| 1296 | continue; | 
|---|
| 1297 | } | 
|---|
| 1298 |  | 
|---|
| 1299 | howto = i370_elf_howto_table[(int)r_type]; | 
|---|
| 1300 | r_symndx = ELF32_R_SYM (rel->r_info); | 
|---|
| 1301 |  | 
|---|
| 1302 | if (r_symndx < symtab_hdr->sh_info) | 
|---|
| 1303 | { | 
|---|
| 1304 | sym = local_syms + r_symndx; | 
|---|
| 1305 | sec = local_sections[r_symndx]; | 
|---|
| 1306 | sym_name = "<local symbol>"; | 
|---|
| 1307 |  | 
|---|
| 1308 | relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel); | 
|---|
| 1309 | addend = rel->r_addend; | 
|---|
| 1310 | } | 
|---|
| 1311 | else | 
|---|
| 1312 | { | 
|---|
| 1313 | h = sym_hashes[r_symndx - symtab_hdr->sh_info]; | 
|---|
| 1314 | while (h->root.type == bfd_link_hash_indirect | 
|---|
| 1315 | || h->root.type == bfd_link_hash_warning) | 
|---|
| 1316 | h = (struct elf_link_hash_entry *) h->root.u.i.link; | 
|---|
| 1317 | sym_name = h->root.root.string; | 
|---|
| 1318 | if (h->root.type == bfd_link_hash_defined | 
|---|
| 1319 | || h->root.type == bfd_link_hash_defweak) | 
|---|
| 1320 | { | 
|---|
| 1321 | sec = h->root.u.def.section; | 
|---|
| 1322 | if (info->shared | 
|---|
| 1323 | && ((! info->symbolic && h->dynindx != -1) | 
|---|
| 1324 | || (h->elf_link_hash_flags | 
|---|
| 1325 | & ELF_LINK_HASH_DEF_REGULAR) == 0) | 
|---|
| 1326 | && (input_section->flags & SEC_ALLOC) != 0 | 
|---|
| 1327 | && (r_type == R_I370_ADDR31 | 
|---|
| 1328 | || r_type == R_I370_COPY | 
|---|
| 1329 | || r_type == R_I370_ADDR16 | 
|---|
| 1330 | || r_type == R_I370_RELATIVE)) | 
|---|
| 1331 | { | 
|---|
| 1332 | /* In these cases, we don't need the relocation | 
|---|
| 1333 | value.  We check specially because in some | 
|---|
| 1334 | obscure cases sec->output_section will be NULL.  */ | 
|---|
| 1335 | relocation = 0; | 
|---|
| 1336 | } | 
|---|
| 1337 | else | 
|---|
| 1338 | relocation = (h->root.u.def.value | 
|---|
| 1339 | + sec->output_section->vma | 
|---|
| 1340 | + sec->output_offset); | 
|---|
| 1341 | } | 
|---|
| 1342 | else if (h->root.type == bfd_link_hash_undefweak) | 
|---|
| 1343 | relocation = 0; | 
|---|
| 1344 | else if (info->shared | 
|---|
| 1345 | && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT) | 
|---|
| 1346 | relocation = 0; | 
|---|
| 1347 | else | 
|---|
| 1348 | { | 
|---|
| 1349 | (*info->callbacks->undefined_symbol) (info, | 
|---|
| 1350 | h->root.root.string, | 
|---|
| 1351 | input_bfd, | 
|---|
| 1352 | input_section, | 
|---|
| 1353 | rel->r_offset, | 
|---|
| 1354 | TRUE); | 
|---|
| 1355 | ret = FALSE; | 
|---|
| 1356 | continue; | 
|---|
| 1357 | } | 
|---|
| 1358 | } | 
|---|
| 1359 |  | 
|---|
| 1360 | switch ((int) r_type) | 
|---|
| 1361 | { | 
|---|
| 1362 | default: | 
|---|
| 1363 | (*_bfd_error_handler) | 
|---|
| 1364 | ("%s: unknown relocation type %d for symbol %s", | 
|---|
| 1365 | bfd_archive_filename (input_bfd), | 
|---|
| 1366 | (int) r_type, sym_name); | 
|---|
| 1367 |  | 
|---|
| 1368 | bfd_set_error (bfd_error_bad_value); | 
|---|
| 1369 | ret = FALSE; | 
|---|
| 1370 | continue; | 
|---|
| 1371 |  | 
|---|
| 1372 | case (int)R_I370_NONE: | 
|---|
| 1373 | continue; | 
|---|
| 1374 |  | 
|---|
| 1375 | /* Relocations that may need to be propagated if this is a shared | 
|---|
| 1376 | object.  */ | 
|---|
| 1377 | case (int)R_I370_REL31: | 
|---|
| 1378 | /* If these relocations are not to a named symbol, they can be | 
|---|
| 1379 | handled right here, no need to bother the dynamic linker.  */ | 
|---|
| 1380 | if (h == NULL | 
|---|
| 1381 | || strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0) | 
|---|
| 1382 | break; | 
|---|
| 1383 | /* fall through */ | 
|---|
| 1384 |  | 
|---|
| 1385 | /* Relocations that always need to be propagated if this is a shared | 
|---|
| 1386 | object.  */ | 
|---|
| 1387 | case (int)R_I370_ADDR31: | 
|---|
| 1388 | case (int)R_I370_ADDR16: | 
|---|
| 1389 | if (info->shared | 
|---|
| 1390 | && r_symndx != 0) | 
|---|
| 1391 | { | 
|---|
| 1392 | Elf_Internal_Rela outrel; | 
|---|
| 1393 | bfd_byte *loc; | 
|---|
| 1394 | int skip; | 
|---|
| 1395 |  | 
|---|
| 1396 | #ifdef DEBUG | 
|---|
| 1397 | fprintf (stderr, | 
|---|
| 1398 | "i370_elf_relocate_section needs to create relocation for %s\n", | 
|---|
| 1399 | (h && h->root.root.string) ? h->root.root.string : "<unknown>"); | 
|---|
| 1400 | #endif | 
|---|
| 1401 |  | 
|---|
| 1402 | /* When generating a shared object, these relocations | 
|---|
| 1403 | are copied into the output file to be resolved at run | 
|---|
| 1404 | time.  */ | 
|---|
| 1405 |  | 
|---|
| 1406 | if (sreloc == NULL) | 
|---|
| 1407 | { | 
|---|
| 1408 | const char *name; | 
|---|
| 1409 |  | 
|---|
| 1410 | name = (bfd_elf_string_from_elf_section | 
|---|
| 1411 | (input_bfd, | 
|---|
| 1412 | elf_elfheader (input_bfd)->e_shstrndx, | 
|---|
| 1413 | elf_section_data (input_section)->rel_hdr.sh_name)); | 
|---|
| 1414 | if (name == NULL) | 
|---|
| 1415 | return FALSE; | 
|---|
| 1416 |  | 
|---|
| 1417 | BFD_ASSERT (strncmp (name, ".rela", 5) == 0 | 
|---|
| 1418 | && strcmp (bfd_get_section_name (input_bfd, | 
|---|
| 1419 | input_section), | 
|---|
| 1420 | name + 5) == 0); | 
|---|
| 1421 |  | 
|---|
| 1422 | sreloc = bfd_get_section_by_name (dynobj, name); | 
|---|
| 1423 | BFD_ASSERT (sreloc != NULL); | 
|---|
| 1424 | } | 
|---|
| 1425 |  | 
|---|
| 1426 | skip = 0; | 
|---|
| 1427 |  | 
|---|
| 1428 | outrel.r_offset = | 
|---|
| 1429 | _bfd_elf_section_offset (output_bfd, info, input_section, | 
|---|
| 1430 | rel->r_offset); | 
|---|
| 1431 | if (outrel.r_offset == (bfd_vma) -1 | 
|---|
| 1432 | || outrel.r_offset == (bfd_vma) -2) | 
|---|
| 1433 | skip = (int) outrel.r_offset; | 
|---|
| 1434 | outrel.r_offset += (input_section->output_section->vma | 
|---|
| 1435 | + input_section->output_offset); | 
|---|
| 1436 |  | 
|---|
| 1437 | if (skip) | 
|---|
| 1438 | memset (&outrel, 0, sizeof outrel); | 
|---|
| 1439 | /* h->dynindx may be -1 if this symbol was marked to | 
|---|
| 1440 | become local.  */ | 
|---|
| 1441 | else if (h != NULL | 
|---|
| 1442 | && ((! info->symbolic && h->dynindx != -1) | 
|---|
| 1443 | || (h->elf_link_hash_flags | 
|---|
| 1444 | & ELF_LINK_HASH_DEF_REGULAR) == 0)) | 
|---|
| 1445 | { | 
|---|
| 1446 | BFD_ASSERT (h->dynindx != -1); | 
|---|
| 1447 | outrel.r_info = ELF32_R_INFO (h->dynindx, r_type); | 
|---|
| 1448 | outrel.r_addend = rel->r_addend; | 
|---|
| 1449 | } | 
|---|
| 1450 | else | 
|---|
| 1451 | { | 
|---|
| 1452 | if (r_type == R_I370_ADDR31) | 
|---|
| 1453 | { | 
|---|
| 1454 | outrel.r_info = ELF32_R_INFO (0, R_I370_RELATIVE); | 
|---|
| 1455 | outrel.r_addend = relocation + rel->r_addend; | 
|---|
| 1456 | } | 
|---|
| 1457 | else | 
|---|
| 1458 | { | 
|---|
| 1459 | long indx; | 
|---|
| 1460 |  | 
|---|
| 1461 | if (h == NULL) | 
|---|
| 1462 | sec = local_sections[r_symndx]; | 
|---|
| 1463 | else | 
|---|
| 1464 | { | 
|---|
| 1465 | BFD_ASSERT (h->root.type == bfd_link_hash_defined | 
|---|
| 1466 | || (h->root.type | 
|---|
| 1467 | == bfd_link_hash_defweak)); | 
|---|
| 1468 | sec = h->root.u.def.section; | 
|---|
| 1469 | } | 
|---|
| 1470 | if (sec != NULL && bfd_is_abs_section (sec)) | 
|---|
| 1471 | indx = 0; | 
|---|
| 1472 | else if (sec == NULL || sec->owner == NULL) | 
|---|
| 1473 | { | 
|---|
| 1474 | bfd_set_error (bfd_error_bad_value); | 
|---|
| 1475 | return FALSE; | 
|---|
| 1476 | } | 
|---|
| 1477 | else | 
|---|
| 1478 | { | 
|---|
| 1479 | asection *osec; | 
|---|
| 1480 |  | 
|---|
| 1481 | osec = sec->output_section; | 
|---|
| 1482 | indx = elf_section_data (osec)->dynindx; | 
|---|
| 1483 | BFD_ASSERT(indx > 0); | 
|---|
| 1484 | #ifdef DEBUG | 
|---|
| 1485 | if (indx <= 0) | 
|---|
| 1486 | { | 
|---|
| 1487 | printf ("indx=%d section=%s flags=%08x name=%s\n", | 
|---|
| 1488 | indx, osec->name, osec->flags, | 
|---|
| 1489 | h->root.root.string); | 
|---|
| 1490 | } | 
|---|
| 1491 | #endif | 
|---|
| 1492 | } | 
|---|
| 1493 |  | 
|---|
| 1494 | outrel.r_info = ELF32_R_INFO (indx, r_type); | 
|---|
| 1495 | outrel.r_addend = relocation + rel->r_addend; | 
|---|
| 1496 | } | 
|---|
| 1497 | } | 
|---|
| 1498 |  | 
|---|
| 1499 | loc = sreloc->contents; | 
|---|
| 1500 | loc += sreloc->reloc_count++ * sizeof (Elf32_External_Rela); | 
|---|
| 1501 | bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc); | 
|---|
| 1502 |  | 
|---|
| 1503 | /* This reloc will be computed at runtime, so there's no | 
|---|
| 1504 | need to do anything now, unless this is a RELATIVE | 
|---|
| 1505 | reloc in an unallocated section.  */ | 
|---|
| 1506 | if (skip == -1 | 
|---|
| 1507 | || (input_section->flags & SEC_ALLOC) != 0 | 
|---|
| 1508 | || ELF32_R_TYPE (outrel.r_info) != R_I370_RELATIVE) | 
|---|
| 1509 | continue; | 
|---|
| 1510 | } | 
|---|
| 1511 | break; | 
|---|
| 1512 |  | 
|---|
| 1513 | case (int)R_I370_COPY: | 
|---|
| 1514 | case (int)R_I370_RELATIVE: | 
|---|
| 1515 | (*_bfd_error_handler) | 
|---|
| 1516 | ("%s: Relocation %s is not yet supported for symbol %s.", | 
|---|
| 1517 | bfd_archive_filename (input_bfd), | 
|---|
| 1518 | i370_elf_howto_table[(int) r_type]->name, | 
|---|
| 1519 | sym_name); | 
|---|
| 1520 |  | 
|---|
| 1521 | bfd_set_error (bfd_error_invalid_operation); | 
|---|
| 1522 | ret = FALSE; | 
|---|
| 1523 | continue; | 
|---|
| 1524 | } | 
|---|
| 1525 |  | 
|---|
| 1526 | #ifdef DEBUG | 
|---|
| 1527 | fprintf (stderr, "\ttype = %s (%d), name = %s, symbol index = %ld, offset = %ld, addend = %ld\n", | 
|---|
| 1528 | howto->name, | 
|---|
| 1529 | (int)r_type, | 
|---|
| 1530 | sym_name, | 
|---|
| 1531 | r_symndx, | 
|---|
| 1532 | (long)offset, | 
|---|
| 1533 | (long)addend); | 
|---|
| 1534 | #endif | 
|---|
| 1535 |  | 
|---|
| 1536 | r = _bfd_final_link_relocate (howto, | 
|---|
| 1537 | input_bfd, | 
|---|
| 1538 | input_section, | 
|---|
| 1539 | contents, | 
|---|
| 1540 | offset, | 
|---|
| 1541 | relocation, | 
|---|
| 1542 | addend); | 
|---|
| 1543 |  | 
|---|
| 1544 | if (r != bfd_reloc_ok) | 
|---|
| 1545 | { | 
|---|
| 1546 | ret = FALSE; | 
|---|
| 1547 | switch (r) | 
|---|
| 1548 | { | 
|---|
| 1549 | default: | 
|---|
| 1550 | break; | 
|---|
| 1551 |  | 
|---|
| 1552 | case bfd_reloc_overflow: | 
|---|
| 1553 | { | 
|---|
| 1554 | const char *name; | 
|---|
| 1555 |  | 
|---|
| 1556 | if (h != NULL) | 
|---|
| 1557 | name = h->root.root.string; | 
|---|
| 1558 | else | 
|---|
| 1559 | { | 
|---|
| 1560 | name = bfd_elf_string_from_elf_section (input_bfd, | 
|---|
| 1561 | symtab_hdr->sh_link, | 
|---|
| 1562 | sym->st_name); | 
|---|
| 1563 | if (name == NULL) | 
|---|
| 1564 | break; | 
|---|
| 1565 |  | 
|---|
| 1566 | if (*name == '\0') | 
|---|
| 1567 | name = bfd_section_name (input_bfd, sec); | 
|---|
| 1568 | } | 
|---|
| 1569 |  | 
|---|
| 1570 | (*info->callbacks->reloc_overflow) (info, | 
|---|
| 1571 | name, | 
|---|
| 1572 | howto->name, | 
|---|
| 1573 | (bfd_vma) 0, | 
|---|
| 1574 | input_bfd, | 
|---|
| 1575 | input_section, | 
|---|
| 1576 | offset); | 
|---|
| 1577 | } | 
|---|
| 1578 | break; | 
|---|
| 1579 |  | 
|---|
| 1580 | } | 
|---|
| 1581 | } | 
|---|
| 1582 | } | 
|---|
| 1583 |  | 
|---|
| 1584 | #ifdef DEBUG | 
|---|
| 1585 | fprintf (stderr, "\n"); | 
|---|
| 1586 | #endif | 
|---|
| 1587 |  | 
|---|
| 1588 | return ret; | 
|---|
| 1589 | } | 
|---|
| 1590 |  | 
|---|
| 1591 | static void | 
|---|
| 1592 | i370_elf_post_process_headers (abfd, link_info) | 
|---|
| 1593 | bfd * abfd; | 
|---|
| 1594 | struct bfd_link_info * link_info ATTRIBUTE_UNUSED; | 
|---|
| 1595 | { | 
|---|
| 1596 | Elf_Internal_Ehdr * i_ehdrp;  /* Elf file header, internal form */ | 
|---|
| 1597 |  | 
|---|
| 1598 | i_ehdrp = elf_elfheader (abfd); | 
|---|
| 1599 | i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_LINUX; | 
|---|
| 1600 | } | 
|---|
| 1601 |  | 
|---|
| 1602 |  | 
|---|
| 1603 | #define TARGET_BIG_SYM          bfd_elf32_i370_vec | 
|---|
| 1604 | #define TARGET_BIG_NAME         "elf32-i370" | 
|---|
| 1605 | #define ELF_ARCH                bfd_arch_i370 | 
|---|
| 1606 | #define ELF_MACHINE_CODE        EM_S370 | 
|---|
| 1607 | #ifdef EM_I370_OLD | 
|---|
| 1608 | #define ELF_MACHINE_ALT1        EM_I370_OLD | 
|---|
| 1609 | #endif | 
|---|
| 1610 | #define ELF_MAXPAGESIZE         0x1000 | 
|---|
| 1611 | #define elf_info_to_howto       i370_elf_info_to_howto | 
|---|
| 1612 |  | 
|---|
| 1613 | #define elf_backend_plt_not_loaded 1 | 
|---|
| 1614 | #define elf_backend_got_symbol_offset 4 | 
|---|
| 1615 | #define elf_backend_rela_normal 1 | 
|---|
| 1616 |  | 
|---|
| 1617 | #define bfd_elf32_bfd_reloc_type_lookup         i370_elf_reloc_type_lookup | 
|---|
| 1618 | #define bfd_elf32_bfd_set_private_flags         i370_elf_set_private_flags | 
|---|
| 1619 | #define bfd_elf32_bfd_merge_private_bfd_data    i370_elf_merge_private_bfd_data | 
|---|
| 1620 | #define elf_backend_relocate_section            i370_elf_relocate_section | 
|---|
| 1621 |  | 
|---|
| 1622 | /* dynamic loader support is mostly broken; just enough here to be able to | 
|---|
| 1623 | * link glibc's ld.so without errors. | 
|---|
| 1624 | */ | 
|---|
| 1625 | #define elf_backend_create_dynamic_sections     i370_elf_create_dynamic_sections | 
|---|
| 1626 | #define elf_backend_size_dynamic_sections       i370_elf_size_dynamic_sections | 
|---|
| 1627 | #define elf_backend_finish_dynamic_sections     i370_elf_finish_dynamic_sections | 
|---|
| 1628 | #define elf_backend_fake_sections               i370_elf_fake_sections | 
|---|
| 1629 | #define elf_backend_section_from_shdr           i370_elf_section_from_shdr | 
|---|
| 1630 | #define elf_backend_adjust_dynamic_symbol       i370_elf_adjust_dynamic_symbol | 
|---|
| 1631 | #define elf_backend_check_relocs                i370_elf_check_relocs | 
|---|
| 1632 |  | 
|---|
| 1633 | /* | 
|---|
| 1634 | #define elf_backend_add_symbol_hook             i370_elf_add_symbol_hook | 
|---|
| 1635 | #define elf_backend_finish_dynamic_symbol       i370_elf_finish_dynamic_symbol | 
|---|
| 1636 | #define elf_backend_additional_program_headers  i370_elf_additional_program_headers | 
|---|
| 1637 | #define elf_backend_modify_segment_map          i370_elf_modify_segment_map | 
|---|
| 1638 | */ | 
|---|
| 1639 |  | 
|---|
| 1640 | #define elf_backend_post_process_headers        i370_elf_post_process_headers | 
|---|
| 1641 |  | 
|---|
| 1642 | static int i370_noop | 
|---|
| 1643 | PARAMS ((void)); | 
|---|
| 1644 |  | 
|---|
| 1645 | static int i370_noop () | 
|---|
| 1646 | { | 
|---|
| 1647 | return 1; | 
|---|
| 1648 | } | 
|---|
| 1649 |  | 
|---|
| 1650 | /* we need to define these at least as no-ops to link glibc ld.so */ | 
|---|
| 1651 |  | 
|---|
| 1652 | #define elf_backend_add_symbol_hook \ | 
|---|
| 1653 | (bfd_boolean (*) \ | 
|---|
| 1654 | PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *, \ | 
|---|
| 1655 | const char **, flagword *, asection **, bfd_vma *))) i370_noop | 
|---|
| 1656 | #define elf_backend_finish_dynamic_symbol \ | 
|---|
| 1657 | (bfd_boolean (*) \ | 
|---|
| 1658 | PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *, \ | 
|---|
| 1659 | Elf_Internal_Sym *))) i370_noop | 
|---|
| 1660 | #define elf_backend_additional_program_headers \ | 
|---|
| 1661 | (int (*) PARAMS ((bfd *))) i370_noop | 
|---|
| 1662 | #define elf_backend_modify_segment_map \ | 
|---|
| 1663 | (bfd_boolean (*) PARAMS ((bfd *))) i370_noop | 
|---|
| 1664 |  | 
|---|
| 1665 | #include "elf32-target.h" | 
|---|