Ignore:
Timestamp:
Aug 16, 2003, 6:59:22 PM (22 years ago)
Author:
bird
Message:

binutils v2.14 - offical sources.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/GNU/src/binutils/bfd/elf32-i370.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r608 r609  
    11/* i370-specific support for 32-bit ELF
    2    Copyright 1994, 1995, 1996, 1997, 1998, 2000, 2001
     2   Copyright 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002
    33   Free Software Foundation, Inc.
    44   Written by Ian Lance Taylor, Cygnus Support.
     
    3535#include "elf/i370.h"
    3636
    37 #define USE_RELA                /* we want RELA relocations, not REL */
    38 
    39 /* i370 relocations */
    40 /* Note that there is really just one relocation that we currently
    41  * support (and only one that we seem to need, at the moment), and
    42  * that is the 31-bit address relocation.  Note that the 370/390
    43  * only supports a 31-bit (2GB) address space.
    44  */
    45 enum i370_reloc_type
    46 {
    47   R_I370_NONE           =   0,
    48   R_I370_ADDR31         =   1,
    49   R_I370_ADDR32         =   2,
    50   R_I370_ADDR16         =   3,
    51   R_I370_REL31          =   4,
    52   R_I370_REL32          =   5,
    53   R_I370_ADDR12         =   6,
    54   R_I370_REL12          =   7,
    55   R_I370_ADDR8          =   8,
    56   R_I370_REL8           =   9,
    57   R_I370_COPY           =  10,
    58   R_I370_RELATIVE       =  11,
    59 
    60   R_I370_max
    61 };
    62 
    63 
    6437static reloc_howto_type *i370_elf_howto_table[ (int)R_I370_max ];
    6538
     
    7144         2,                     /* size (0 = byte, 1 = short, 2 = long) */
    7245         32,                    /* bitsize */
    73          false,                 /* pc_relative */
     46         FALSE,                 /* pc_relative */
    7447         0,                     /* bitpos */
    7548         complain_overflow_bitfield, /* complain_on_overflow */
    7649         bfd_elf_generic_reloc, /* special_function */
    7750         "R_I370_NONE",         /* name */
    78          false,                 /* partial_inplace */
     51         FALSE,                 /* partial_inplace */
    7952         0,                     /* src_mask */
    8053         0,                     /* dst_mask */
    81          false),                /* pcrel_offset */
     54         FALSE),                /* pcrel_offset */
    8255
    8356  /* A standard 31 bit relocation.  */
     
    8659         2,                     /* size (0 = byte, 1 = short, 2 = long) */
    8760         31,                    /* bitsize */
    88          false,                 /* pc_relative */
     61         FALSE,                 /* pc_relative */
    8962         0,                     /* bitpos */
    9063         complain_overflow_bitfield, /* complain_on_overflow */
    9164         bfd_elf_generic_reloc, /* special_function */
    9265         "R_I370_ADDR31",       /* name */
    93          false,                 /* partial_inplace */
     66         FALSE,                 /* partial_inplace */
    9467         0,                     /* src_mask */
    9568         0x7fffffff,            /* dst_mask */
    96          false),                /* pcrel_offset */
     69         FALSE),                /* pcrel_offset */
    9770
    9871  /* A standard 32 bit relocation.  */
     
    10174         2,                     /* size (0 = byte, 1 = short, 2 = long) */
    10275         32,                    /* bitsize */
    103          false,                 /* pc_relative */
     76         FALSE,                 /* pc_relative */
    10477         0,                     /* bitpos */
    10578         complain_overflow_bitfield, /* complain_on_overflow */
    10679         bfd_elf_generic_reloc, /* special_function */
    10780         "R_I370_ADDR32",       /* name */
    108          false,                 /* partial_inplace */
     81         FALSE,                 /* partial_inplace */
    10982         0,                     /* src_mask */
    11083         0xffffffff,            /* dst_mask */
    111          false),                /* pcrel_offset */
     84         FALSE),                /* pcrel_offset */
    11285
    11386  /* A standard 16 bit relocation.  */
     
    11689         1,                     /* size (0 = byte, 1 = short, 2 = long) */
    11790         16,                    /* bitsize */
    118          false,                 /* pc_relative */
     91         FALSE,                 /* pc_relative */
    11992         0,                     /* bitpos */
    12093         complain_overflow_bitfield, /* complain_on_overflow */
    12194         bfd_elf_generic_reloc, /* special_function */
    12295         "R_I370_ADDR16",       /* name */
    123          false,                 /* partial_inplace */
     96         FALSE,                 /* partial_inplace */
    12497         0,                     /* src_mask */
    12598         0xffff,                /* dst_mask */
    126          false),                /* pcrel_offset */
     99         FALSE),                /* pcrel_offset */
    127100
    128101  /* 31-bit PC relative */
     
    131104         2,                     /* size (0 = byte, 1 = short, 2 = long) */
    132105         31,                    /* bitsize */
    133          true,                  /* pc_relative */
     106         TRUE,                  /* pc_relative */
    134107         0,                     /* bitpos */
    135108         complain_overflow_bitfield, /* complain_on_overflow */
    136109         bfd_elf_generic_reloc, /* special_function */
    137110         "R_I370_REL31",        /* name */
    138          false,                 /* partial_inplace */
     111         FALSE,                 /* partial_inplace */
    139112         0,                     /* src_mask */
    140113         0x7fffffff,            /* dst_mask */
    141          true),                 /* pcrel_offset */
     114         TRUE),                 /* pcrel_offset */
    142115
    143116  /* 32-bit PC relative */
     
    146119         2,                     /* size (0 = byte, 1 = short, 2 = long) */
    147120         32,                    /* bitsize */
    148          true,                  /* pc_relative */
     121         TRUE,                  /* pc_relative */
    149122         0,                     /* bitpos */
    150123         complain_overflow_bitfield, /* complain_on_overflow */
    151124         bfd_elf_generic_reloc, /* special_function */
    152125         "R_I370_REL32",        /* name */
    153          false,                 /* partial_inplace */
     126         FALSE,                 /* partial_inplace */
    154127         0,                     /* src_mask */
    155128         0xffffffff,            /* dst_mask */
    156          true),                 /* pcrel_offset */
     129         TRUE),                 /* pcrel_offset */
    157130
    158131  /* A standard 12 bit relocation.  */
     
    161134         1,                     /* size (0 = byte, 1 = short, 2 = long) */
    162135         12,                    /* bitsize */
    163          false,                 /* pc_relative */
     136         FALSE,                 /* pc_relative */
    164137         0,                     /* bitpos */
    165138         complain_overflow_bitfield, /* complain_on_overflow */
    166139         bfd_elf_generic_reloc, /* special_function */
    167140         "R_I370_ADDR12",       /* name */
    168          false,                 /* partial_inplace */
     141         FALSE,                 /* partial_inplace */
    169142         0,                     /* src_mask */
    170143         0xfff,                 /* dst_mask */
    171          false),                /* pcrel_offset */
     144         FALSE),                /* pcrel_offset */
    172145
    173146  /* 12-bit PC relative */
     
    176149         1,                     /* size (0 = byte, 1 = short, 2 = long) */
    177150         12,                    /* bitsize */
    178          true,                  /* pc_relative */
     151         TRUE,                  /* pc_relative */
    179152         0,                     /* bitpos */
    180153         complain_overflow_bitfield, /* complain_on_overflow */
    181154         bfd_elf_generic_reloc, /* special_function */
    182155         "R_I370_REL12",        /* name */
    183          false,                 /* partial_inplace */
     156         FALSE,                 /* partial_inplace */
    184157         0,                     /* src_mask */
    185158         0xfff,                 /* dst_mask */
    186          true),                 /* pcrel_offset */
     159         TRUE),                 /* pcrel_offset */
    187160
    188161  /* A standard 8 bit relocation.  */
     
    191164         0,                     /* size (0 = byte, 1 = short, 2 = long) */
    192165         8,                     /* bitsize */
    193          false,                 /* pc_relative */
     166         FALSE,                 /* pc_relative */
    194167         0,                     /* bitpos */
    195168         complain_overflow_bitfield, /* complain_on_overflow */
    196169         bfd_elf_generic_reloc, /* special_function */
    197170         "R_I370_ADDR8",        /* name */
    198          false,                 /* partial_inplace */
     171         FALSE,                 /* partial_inplace */
    199172         0,                     /* src_mask */
    200173         0xff,                  /* dst_mask */
    201          false),                /* pcrel_offset */
     174         FALSE),                /* pcrel_offset */
    202175
    203176  /* 8-bit PC relative */
     
    206179         0,                     /* size (0 = byte, 1 = short, 2 = long) */
    207180         8,                     /* bitsize */
    208          true,                  /* pc_relative */
     181         TRUE,                  /* pc_relative */
    209182         0,                     /* bitpos */
    210183         complain_overflow_bitfield, /* complain_on_overflow */
    211184         bfd_elf_generic_reloc, /* special_function */
    212185         "R_I370_REL8",         /* name */
    213          false,                 /* partial_inplace */
     186         FALSE,                 /* partial_inplace */
    214187         0,                     /* src_mask */
    215188         0xff,                  /* dst_mask */
    216          true),                 /* pcrel_offset */
     189         TRUE),                 /* pcrel_offset */
    217190
    218191  /* This is used only by the dynamic linker.  The symbol should exist
     
    225198         2,                     /* size (0 = byte, 1 = short, 2 = long) */
    226199         32,                    /* bitsize */
    227          false,                 /* pc_relative */
     200         FALSE,                 /* pc_relative */
    228201         0,                     /* bitpos */
    229202         complain_overflow_bitfield, /* complain_on_overflow */
    230203         bfd_elf_generic_reloc,  /* special_function */
    231204         "R_I370_COPY",         /* name */
    232          false,                 /* partial_inplace */
     205         FALSE,                 /* partial_inplace */
    233206         0,                     /* src_mask */
    234207         0,                     /* dst_mask */
    235          false),                /* pcrel_offset */
     208         FALSE),                /* pcrel_offset */
    236209
    237210  /* Used only by the dynamic linker.  When the object is run, this
     
    242215         2,                     /* size (0 = byte, 1 = short, 2 = long) */
    243216         32,                    /* bitsize */
    244          false,                 /* pc_relative */
     217         FALSE,                 /* pc_relative */
    245218         0,                     /* bitpos */
    246219         complain_overflow_bitfield, /* complain_on_overflow */
    247220         bfd_elf_generic_reloc,  /* special_function */
    248221         "R_I370_RELATIVE",     /* name */
    249          false,                 /* partial_inplace */
     222         FALSE,                 /* partial_inplace */
    250223         0,                     /* src_mask */
    251224         0xffffffff,            /* dst_mask */
    252          false),                /* pcrel_offset */
     225         FALSE),                /* pcrel_offset */
    253226
    254227};
    255228
    256229
    257 static void i370_elf_howto_init PARAMS ((void));
    258 static void i370_elf_info_to_howto PARAMS ((bfd *abfd, arelent *cache_ptr,
    259                                             Elf32_Internal_Rela *dst));
    260 static boolean i370_elf_set_private_flags PARAMS ((bfd *, flagword));
     230static void i370_elf_howto_init
     231  PARAMS ((void));
     232static reloc_howto_type *i370_elf_reloc_type_lookup
     233  PARAMS ((bfd *, bfd_reloc_code_real_type));
     234static void i370_elf_info_to_howto
     235  PARAMS ((bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst));
     236static bfd_boolean i370_elf_set_private_flags
     237  PARAMS ((bfd *, flagword));
    261238
    262239
     
    303280};
    304281
    305 static boolean i370_elf_copy_private_bfd_data PARAMS ((bfd *, bfd *));
    306 static boolean i370_elf_merge_private_bfd_data PARAMS ((bfd *, bfd *));
    307 
    308 static boolean i370_elf_relocate_section PARAMS ((bfd *,
    309                                                   struct bfd_link_info *info,
    310                                                   bfd *,
    311                                                   asection *,
    312                                                   bfd_byte *,
    313                                                   Elf_Internal_Rela *relocs,
    314                                                   Elf_Internal_Sym *local_syms,
    315                                                   asection **));
    316 
    317 static boolean i370_elf_create_dynamic_sections PARAMS ((bfd *,
    318                                                          struct bfd_link_info *));
    319 
    320 static boolean i370_elf_section_from_shdr PARAMS ((bfd *,
    321                                                    Elf32_Internal_Shdr *,
    322                                                    char *));
    323 static boolean i370_elf_fake_sections PARAMS ((bfd *,
    324                                                Elf32_Internal_Shdr *,
    325                                                asection *));
     282static bfd_boolean i370_elf_merge_private_bfd_data
     283  PARAMS ((bfd *, bfd *));
     284static 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 **));
     288static void i370_elf_post_process_headers
     289  PARAMS ((bfd *, struct bfd_link_info *));
     290static bfd_boolean i370_elf_create_dynamic_sections
     291  PARAMS ((bfd *, struct bfd_link_info *));
     292static bfd_boolean i370_elf_section_from_shdr
     293  PARAMS ((bfd *, Elf_Internal_Shdr *, const char *));
     294static bfd_boolean i370_elf_fake_sections
     295  PARAMS ((bfd *, Elf_Internal_Shdr *, asection *));
    326296#if 0
    327297static elf_linker_section_t *i370_elf_create_linker_section
    328   PARAMS ((bfd *abfd,
    329            struct bfd_link_info *info,
     298  PARAMS ((bfd *abfd, struct bfd_link_info *info,
    330299           enum elf_linker_section_enum));
    331300#endif
    332 static boolean i370_elf_check_relocs PARAMS ((bfd *,
    333                                              struct bfd_link_info *,
    334                                              asection *,
    335                                              const Elf_Internal_Rela *));
    336 
    337 static boolean i370_elf_adjust_dynamic_symbol PARAMS ((struct bfd_link_info *,
    338                                                       struct elf_link_hash_entry *));
    339 
    340 static boolean i370_elf_adjust_dynindx PARAMS ((struct elf_link_hash_entry *, PTR));
    341 
    342 static boolean i370_elf_size_dynamic_sections PARAMS ((bfd *, struct bfd_link_info *));
    343 
    344 static boolean i370_elf_finish_dynamic_sections PARAMS ((bfd *, struct bfd_link_info *));
     301static bfd_boolean i370_elf_check_relocs
     302  PARAMS ((bfd *, struct bfd_link_info *, asection *,
     303           const Elf_Internal_Rela *));
     304static bfd_boolean i370_elf_adjust_dynamic_symbol
     305  PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
     306static bfd_boolean i370_elf_adjust_dynindx
     307  PARAMS ((struct elf_link_hash_entry *, PTR));
     308static bfd_boolean i370_elf_size_dynamic_sections
     309  PARAMS ((bfd *, struct bfd_link_info *));
     310static bfd_boolean i370_elf_finish_dynamic_sections
     311  PARAMS ((bfd *, struct bfd_link_info *));
    345312
    346313/* The name of the dynamic interpreter.  This is put in the .interp
     
    355322     bfd *abfd ATTRIBUTE_UNUSED;
    356323     arelent *cache_ptr;
    357      Elf32_Internal_Rela *dst;
     324     Elf_Internal_Rela *dst;
    358325{
    359326  if (!i370_elf_howto_table[ R_I370_ADDR31 ])   /* Initialize howto table */
     
    368335 */
    369336/* Function to set whether a module needs the -mrelocatable bit set.  */
    370 static boolean
     337static bfd_boolean
    371338i370_elf_set_private_flags (abfd, flags)
    372339     bfd *abfd;
     
    377344
    378345  elf_elfheader (abfd)->e_flags = flags;
    379   elf_flags_init (abfd) = true;
    380   return true;
    381 }
    382 
    383 /* Copy backend specific data from one object module to another */
    384 static boolean
    385 i370_elf_copy_private_bfd_data (ibfd, obfd)
    386      bfd *ibfd;
    387      bfd *obfd;
    388 {
    389   if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
    390       || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
    391     return true;
    392 
    393   BFD_ASSERT (!elf_flags_init (obfd)
    394               || elf_elfheader (obfd)->e_flags == elf_elfheader (ibfd)->e_flags);
    395 
    396   elf_elfheader (obfd)->e_flags = elf_elfheader (ibfd)->e_flags;
    397   elf_flags_init (obfd) = true;
    398   return true;
     346  elf_flags_init (abfd) = TRUE;
     347  return TRUE;
    399348}
    400349
    401350/* Merge backend specific data from an object file to the output
    402351   object file when linking */
    403 static boolean
     352static bfd_boolean
    404353i370_elf_merge_private_bfd_data (ibfd, obfd)
    405354     bfd *ibfd;
     
    411360  if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
    412361      || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
    413     return true;
     362    return TRUE;
    414363
    415364  new_flags = elf_elfheader (ibfd)->e_flags;
     
    417366  if (!elf_flags_init (obfd))   /* First call, no flags set */
    418367    {
    419       elf_flags_init (obfd) = true;
     368      elf_flags_init (obfd) = TRUE;
    420369      elf_elfheader (obfd)->e_flags = new_flags;
    421370    }
     
    428377      (*_bfd_error_handler)
    429378        ("%s: uses different e_flags (0x%lx) fields than previous modules (0x%lx)",
    430          bfd_get_filename (ibfd), (long)new_flags, (long)old_flags);
     379         bfd_archive_filename (ibfd), (long) new_flags, (long) old_flags);
    431380
    432381      bfd_set_error (bfd_error_bad_value);
    433       return false;
    434     }
    435 
    436   return true;
     382      return FALSE;
     383    }
     384
     385  return TRUE;
    437386}
    438387
     
    445394 */
    446395
    447 static boolean
     396static bfd_boolean
    448397i370_elf_section_from_shdr (abfd, hdr, name)
    449398     bfd *abfd;
    450      Elf32_Internal_Shdr *hdr;
    451      char *name;
     399     Elf_Internal_Shdr *hdr;
     400     const char *name;
    452401{
    453402  asection *newsect;
     
    455404
    456405  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
    457     return false;
     406    return FALSE;
    458407
    459408  newsect = hdr->bfd_section;
     
    466415
    467416  bfd_set_section_flags (abfd, newsect, flags);
    468   return true;
     417  return TRUE;
    469418}
    470419
     
    476425 */
    477426
    478 static boolean
     427static bfd_boolean
    479428i370_elf_fake_sections (abfd, shdr, asect)
    480429     bfd *abfd ATTRIBUTE_UNUSED;
    481      Elf32_Internal_Shdr *shdr;
     430     Elf_Internal_Shdr *shdr;
    482431     asection *asect;
    483432{
     
    488437    shdr->sh_type = SHT_ORDERED;
    489438
    490   return true;
     439  return TRUE;
    491440}
    492441
     
    521470      defaults = zero_section;
    522471      defaults.which = which;
    523       defaults.hole_written_p = false;
     472      defaults.hole_written_p = FALSE;
    524473      defaults.alignment = 2;
    525474
     
    539488        default:
    540489          (*_bfd_error_handler) ("%s: Unknown special linker type %d",
    541                                  bfd_get_filename (abfd),
    542                                  (int)which);
     490                                 bfd_archive_filename (abfd),
     491                                 (int) which);
    543492
    544493          bfd_set_error (bfd_error_bad_value);
     
    579528 */
    580529
    581 static boolean
     530static bfd_boolean
    582531i370_elf_create_dynamic_sections (abfd, info)
    583532     bfd *abfd;
     
    588537
    589538  if (!_bfd_elf_create_dynamic_sections(abfd, info))
    590     return false;
     539    return FALSE;
    591540
    592541  flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
     
    596545  if (s == NULL
    597546      || ! bfd_set_section_flags (abfd, s, SEC_ALLOC))
    598     return false;
     547    return FALSE;
    599548
    600549  if (! info->shared)
     
    604553          || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
    605554          || ! bfd_set_section_alignment (abfd, s, 2))
    606         return false;
     555        return FALSE;
    607556    }
    608557
     
    612561      || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
    613562      || ! bfd_set_section_alignment (abfd, s, 2))
    614     return false;
    615   return true;
     563    return FALSE;
     564  return TRUE;
    616565}
    617566
     
    626575 */
    627576
    628 static boolean
     577static bfd_boolean
    629578i370_elf_adjust_dynamic_symbol (info, h)
    630579     struct bfd_link_info *info;
     
    664613      h->root.u.def.section = h->weakdef->root.u.def.section;
    665614      h->root.u.def.value = h->weakdef->root.u.def.value;
    666       return true;
     615      return TRUE;
    667616    }
    668617
     
    675624     be handled correctly by relocate_section.  */
    676625  if (info->shared)
    677     return true;
     626    return TRUE;
    678627
    679628  /* We must allocate the symbol in our .dynbss section, which will
     
    726675    {
    727676      if (! bfd_set_section_alignment (dynobj, s, power_of_two))
    728         return false;
     677        return FALSE;
    729678    }
    730679
     
    736685  s->_raw_size += h->size;
    737686
    738   return true;
     687  return TRUE;
    739688}
    740689
     
    747696 */
    748697
    749 static boolean
     698static bfd_boolean
    750699i370_elf_adjust_dynindx (h, cparg)
    751700     struct elf_link_hash_entry *h;
     
    760709#endif
    761710
     711  if (h->root.type == bfd_link_hash_warning)
     712    h = (struct elf_link_hash_entry *) h->root.u.i.link;
     713
    762714  if (h->dynindx != -1)
    763715    h->dynindx += *cp;
    764716
    765   return true;
     717  return TRUE;
    766718}
    767719
     
    773725 */
    774726
    775 static boolean
     727static bfd_boolean
    776728i370_elf_size_dynamic_sections (output_bfd, info)
    777729     bfd *output_bfd;
     
    780732  bfd *dynobj;
    781733  asection *s;
    782   boolean plt;
    783   boolean relocs;
    784   boolean reltext;
     734  bfd_boolean plt;
     735  bfd_boolean relocs;
     736  bfd_boolean reltext;
    785737
    786738#ifdef DEBUG
     
    825777     determined the sizes of the various dynamic sections.  Allocate
    826778     memory for them.  */
    827   plt = false;
    828   relocs = false;
    829   reltext = false;
     779  plt = FALSE;
     780  relocs = FALSE;
     781  reltext = FALSE;
    830782  for (s = dynobj->sections; s != NULL; s = s->next)
    831783    {
    832784      const char *name;
    833       boolean strip;
     785      bfd_boolean strip;
    834786
    835787      if ((s->flags & SEC_LINKER_CREATED) == 0)
     
    839791         of the dynobj section names depend upon the input files.  */
    840792      name = bfd_get_section_name (dynobj, s);
    841       strip = false;
     793      strip = FALSE;
    842794
    843795      if (strcmp (name, ".plt") == 0)
     
    847799              /* Strip this section if we don't need it; see the
    848800                 comment below.  */
    849               strip = true;
     801              strip = TRUE;
    850802            }
    851803          else
    852804            {
    853805              /* Remember whether there is a PLT.  */
    854               plt = true;
     806              plt = TRUE;
    855807            }
    856808        }
     
    868820                 function which decides whether anything needs to go
    869821                 into these sections.  */
    870               strip = true;
     822              strip = TRUE;
    871823            }
    872824          else
     
    876828
    877829              /* Remember whether there are any relocation sections.  */
    878               relocs = true;
     830              relocs = TRUE;
    879831
    880832              /* If this relocation section applies to a read only
     
    886838                  && (target->flags & SEC_READONLY) != 0
    887839                  && (target->flags & SEC_ALLOC) != 0)
    888                 reltext = true;
     840                reltext = TRUE;
    889841
    890842              /* We use the reloc_count field as a counter if we need
     
    906858
    907859          for (spp = &s->output_section->owner->sections;
    908                *spp != s->output_section;
     860               *spp != NULL;
    909861               spp = &(*spp)->next)
    910             ;
    911           *spp = s->output_section->next;
    912           --s->output_section->owner->section_count;
    913 
     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            }
    914870          continue;
    915871        }
     
    917873      s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size);
    918874      if (s->contents == NULL && s->_raw_size != 0)
    919         return false;
     875        return FALSE;
    920876    }
    921877
     
    927883         the .dynamic section.  The DT_DEBUG entry is filled in by the
    928884         dynamic linker and used by the debugger.  */
    929       if (! info->shared)
    930         {
    931           if (! bfd_elf32_add_dynamic_entry (info, DT_DEBUG, 0))
    932             return false;
     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;
    933892        }
    934893
    935894      if (plt)
    936895        {
    937           if (! bfd_elf32_add_dynamic_entry (info, DT_PLTGOT, 0)
    938               || ! bfd_elf32_add_dynamic_entry (info, DT_PLTRELSZ, 0)
    939               || ! bfd_elf32_add_dynamic_entry (info, DT_PLTREL, DT_RELA)
    940               || ! bfd_elf32_add_dynamic_entry (info, DT_JMPREL, 0))
    941             return false;
     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;
    942901        }
    943902
    944903      if (relocs)
    945904        {
    946           if (! bfd_elf32_add_dynamic_entry (info, DT_RELA, 0)
    947               || ! bfd_elf32_add_dynamic_entry (info, DT_RELASZ, 0)
    948               || ! bfd_elf32_add_dynamic_entry (info, DT_RELAENT,
    949                                                 sizeof (Elf32_External_Rela)))
    950             return false;
     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;
    951909        }
    952910
    953911      if (reltext)
    954912        {
    955           if (! bfd_elf32_add_dynamic_entry (info, DT_TEXTREL, 0))
    956             return false;
     913          if (!add_dynamic_entry (DT_TEXTREL, 0))
     914            return FALSE;
    957915          info->flags |= DF_TEXTREL;
    958916        }
    959917    }
     918#undef add_dynamic_entry
    960919
    961920  /* If we are generating a shared library, we generate a section
     
    996955    }
    997956
    998   return true;
     957  return TRUE;
    999958}
    1000959
     
    1008967 */
    1009968
    1010 static boolean
     969static bfd_boolean
    1011970i370_elf_check_relocs (abfd, info, sec, relocs)
    1012971     bfd *abfd;
     
    1024983
    1025984  if (info->relocateable)
    1026     return true;
     985    return TRUE;
    1027986
    1028987#ifdef DEBUG
    1029988  fprintf (stderr, "i370_elf_check_relocs called for section %s in %s\n",
    1030989           bfd_get_section_name (abfd, sec),
    1031            bfd_get_filename (abfd));
     990           bfd_archive_filename (abfd));
    1032991#endif
    1033992
     
    10681027                       elf_section_data (sec)->rel_hdr.sh_name));
    10691028              if (name == NULL)
    1070                 return false;
     1029                return FALSE;
    10711030
    10721031              BFD_ASSERT (strncmp (name, ".rela", 5) == 0
     
    10861045                      || ! bfd_set_section_flags (dynobj, sreloc, flags)
    10871046                      || ! bfd_set_section_alignment (dynobj, sreloc, 2))
    1088                     return false;
     1047                    return FALSE;
    10891048                }
    10901049            }
     
    11011060    }
    11021061
    1103   return true;
     1062  return TRUE;
    11041063}
    11051064
     
    11111070 */
    11121071
    1113 static boolean
     1072static bfd_boolean
    11141073i370_elf_finish_dynamic_sections (output_bfd, info)
    11151074     bfd *output_bfd;
     
    11401099          Elf_Internal_Dyn dyn;
    11411100          const char *name;
    1142           boolean size;
     1101          bfd_boolean size;
    11431102
    11441103          bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn);
     
    11461105          switch (dyn.d_tag)
    11471106            {
    1148             case DT_PLTGOT:   name = ".plt";      size = false; break;
    1149             case DT_PLTRELSZ: name = ".rela.plt"; size = true;  break;
    1150             case DT_JMPREL:   name = ".rela.plt"; size = false; break;
    1151             default:          name = NULL;        size = false; break;
     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;
    11521111            }
    11531112
     
    11821141    {
    11831142      unsigned char *contents = sgot->contents;
    1184       bfd_put_32 (output_bfd, 0x4e800021 /* blrl */, contents);
     1143      bfd_put_32 (output_bfd, (bfd_vma) 0x4e800021 /* blrl */, contents);
    11851144
    11861145      if (sdyn == NULL)
     
    12141173        {
    12151174          int indx, dindx;
     1175          Elf32_External_Sym *esym;
    12161176
    12171177          sym.st_value = s->vma;
     
    12291189              sym.st_shndx = indx;
    12301190
    1231               bfd_elf32_swap_symbol_out (output_bfd, &sym,
    1232                                          (PTR) (((Elf32_External_Sym *)
    1233                                                  sdynsym->contents)
    1234                                                 + dindx));
     1191              esym = (Elf32_External_Sym *) sdynsym->contents + dindx;
     1192              bfd_elf32_swap_symbol_out (output_bfd, &sym, (PTR) esym, (PTR) 0);
    12351193            }
    12361194        }
     
    12421200    }
    12431201
    1244   return true;
     1202  return TRUE;
    12451203}
    12461204
     
    12751233   accordingly.  */
    12761234
    1277 static boolean
     1235static bfd_boolean
    12781236i370_elf_relocate_section (output_bfd, info, input_bfd, input_section,
    1279                           contents, relocs, local_syms, local_sections)
     1237                           contents, relocs, local_syms, local_sections)
    12801238     bfd *output_bfd;
    12811239     struct bfd_link_info *info;
     
    12871245     asection **local_sections;
    12881246{
    1289   Elf_Internal_Shdr *symtab_hdr          = &elf_tdata (input_bfd)->symtab_hdr;
     1247  Elf_Internal_Shdr *symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
    12901248  struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (input_bfd);
    1291   bfd *dynobj                            = elf_hash_table (info)->dynobj;
    1292   Elf_Internal_Rela *rel                  = relocs;
    1293   Elf_Internal_Rela *relend              = relocs + input_section->reloc_count;
    1294   asection *sreloc                        = NULL;
     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;
    12951253  bfd_vma *local_got_offsets;
    1296   boolean ret                             = true;
     1254  bfd_boolean ret = TRUE;
     1255
     1256  if (info->relocateable)
     1257    return TRUE;
    12971258
    12981259#ifdef DEBUG
    12991260  fprintf (stderr, "i370_elf_relocate_section called for %s section %s, %ld relocations%s\n",
    1300            bfd_get_filename (input_bfd),
     1261           bfd_archive_filename (input_bfd),
    13011262           bfd_section_name(input_bfd, input_section),
    1302            (long)input_section->reloc_count,
     1263           (long) input_section->reloc_count,
    13031264           (info->relocateable) ? " (relocatable)" : "");
    13041265#endif
     
    13281289        {
    13291290          (*_bfd_error_handler) ("%s: unknown relocation type %d",
    1330                                  bfd_get_filename (input_bfd),
    1331                                  (int)r_type);
     1291                                 bfd_archive_filename (input_bfd),
     1292                                 (int) r_type);
    13321293
    13331294          bfd_set_error (bfd_error_bad_value);
    1334           ret = false;
     1295          ret = FALSE;
    13351296          continue;
    13361297        }
     
    13391300      r_symndx = ELF32_R_SYM (rel->r_info);
    13401301
    1341       if (info->relocateable)
    1342         {
    1343           /* This is a relocateable link.  We don't have to change
    1344              anything, unless the reloc is against a section symbol,
    1345              in which case we have to adjust according to where the
    1346              section symbol winds up in the output section.  */
    1347           if (r_symndx < symtab_hdr->sh_info)
    1348             {
    1349               sym = local_syms + r_symndx;
    1350               if ((unsigned)ELF_ST_TYPE (sym->st_info) == STT_SECTION)
    1351                 {
    1352                   sec = local_sections[r_symndx];
    1353                   addend = rel->r_addend += sec->output_offset + sym->st_value;
    1354                 }
    1355             }
    1356 
    1357 #ifdef DEBUG
    1358           fprintf (stderr, "\ttype = %s (%d), symbol index = %ld, offset = %ld, addend = %ld\n",
    1359                    howto->name,
    1360                    (int)r_type,
    1361                    r_symndx,
    1362                    (long)offset,
    1363                    (long)addend);
    1364 #endif
    1365           continue;
    1366         }
    1367 
    1368       /* This is a final link.  */
    13691302      if (r_symndx < symtab_hdr->sh_info)
    13701303        {
     
    13731306          sym_name = "<local symbol>";
    13741307
    1375           relocation = (sec->output_section->vma
    1376                         + sec->output_offset
    1377                         + sym->st_value);
     1308          relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
     1309          addend = rel->r_addend;
    13781310        }
    13791311      else
     
    14201352                                                    input_section,
    14211353                                                    rel->r_offset,
    1422                                                     true);
    1423               ret = false;
     1354                                                    TRUE);
     1355              ret = FALSE;
    14241356              continue;
    14251357            }
    14261358        }
    14271359
    1428       switch ((int)r_type)
     1360      switch ((int) r_type)
    14291361        {
    14301362        default:
    1431           (*_bfd_error_handler) ("%s: unknown relocation type %d for symbol %s",
    1432                                  bfd_get_filename (input_bfd),
    1433                                  (int)r_type, sym_name);
     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);
    14341367
    14351368          bfd_set_error (bfd_error_bad_value);
    1436           ret = false;
     1369          ret = FALSE;
     1370          continue;
     1371
     1372        case (int)R_I370_NONE:
    14371373          continue;
    14381374
     
    14491385        /* Relocations that always need to be propagated if this is a shared
    14501386           object.  */
    1451         case (int)R_I370_NONE:
    14521387        case (int)R_I370_ADDR31:
    14531388        case (int)R_I370_ADDR16:
    1454           if (info->shared)
     1389          if (info->shared
     1390              && r_symndx != 0)
    14551391            {
    14561392              Elf_Internal_Rela outrel;
    1457               boolean skip;
     1393              bfd_byte *loc;
     1394              int skip;
    14581395
    14591396#ifdef DEBUG
     
    14761413                           elf_section_data (input_section)->rel_hdr.sh_name));
    14771414                  if (name == NULL)
    1478                     return false;
     1415                    return FALSE;
    14791416
    14801417                  BFD_ASSERT (strncmp (name, ".rela", 5) == 0
     
    14871424                }
    14881425
    1489               skip = false;
    1490 
    1491               if (elf_section_data (input_section)->stab_info == NULL)
    1492                 outrel.r_offset = rel->r_offset;
    1493               else
    1494                 {
    1495                   bfd_vma off;
    1496 
    1497                   off = (_bfd_stab_section_offset
    1498                          (output_bfd, &elf_hash_table (info)->stab_info,
    1499                           input_section,
    1500                           &elf_section_data (input_section)->stab_info,
    1501                           rel->r_offset));
    1502                   if (off == (bfd_vma) -1)
    1503                     skip = true;
    1504                   outrel.r_offset = off;
    1505                 }
    1506 
     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;
    15071434              outrel.r_offset += (input_section->output_section->vma
    15081435                                  + input_section->output_offset);
     
    15461473                        {
    15471474                          bfd_set_error (bfd_error_bad_value);
    1548                           return false;
     1475                          return FALSE;
    15491476                        }
    15501477                      else
     
    15701497                }
    15711498
    1572               bfd_elf32_swap_reloca_out (output_bfd, &outrel,
    1573                                          (((Elf32_External_Rela *)
    1574                                            sreloc->contents)
    1575                                           + sreloc->reloc_count));
    1576               ++sreloc->reloc_count;
     1499              loc = sreloc->contents;
     1500              loc += sreloc->reloc_count++ * sizeof (Elf32_External_Rela);
     1501              bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
    15771502
    15781503              /* This reloc will be computed at runtime, so there's no
    15791504                 need to do anything now, unless this is a RELATIVE
    15801505                 reloc in an unallocated section.  */
    1581               if (skip
     1506              if (skip == -1
    15821507                  || (input_section->flags & SEC_ALLOC) != 0
    15831508                  || ELF32_R_TYPE (outrel.r_info) != R_I370_RELATIVE)
     
    15881513        case (int)R_I370_COPY:
    15891514        case (int)R_I370_RELATIVE:
    1590           (*_bfd_error_handler) ("%s: Relocation %s is not yet supported for symbol %s.",
    1591                                  bfd_get_filename (input_bfd),
    1592                                  i370_elf_howto_table[ (int)r_type ]->name,
    1593                                  sym_name);
     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);
    15941520
    15951521          bfd_set_error (bfd_error_invalid_operation);
    1596           ret = false;
     1522          ret = FALSE;
    15971523          continue;
    15981524        }
     
    16181544      if (r != bfd_reloc_ok)
    16191545        {
    1620           ret = false;
     1546          ret = FALSE;
    16211547          switch (r)
    16221548            {
     
    16871613#define elf_backend_plt_not_loaded 1
    16881614#define elf_backend_got_symbol_offset 4
     1615#define elf_backend_rela_normal 1
    16891616
    16901617#define bfd_elf32_bfd_reloc_type_lookup         i370_elf_reloc_type_lookup
    16911618#define bfd_elf32_bfd_set_private_flags         i370_elf_set_private_flags
    1692 #define bfd_elf32_bfd_copy_private_bfd_data     i370_elf_copy_private_bfd_data
    16931619#define bfd_elf32_bfd_merge_private_bfd_data    i370_elf_merge_private_bfd_data
    16941620#define elf_backend_relocate_section            i370_elf_relocate_section
     
    17141640#define elf_backend_post_process_headers        i370_elf_post_process_headers
    17151641
    1716 int i370_noop()
     1642static int i370_noop
     1643  PARAMS ((void));
     1644
     1645static int i370_noop ()
    17171646{
    17181647  return 1;
     
    17221651
    17231652#define elf_backend_add_symbol_hook \
    1724   (boolean (*) PARAMS ((bfd *, struct bfd_link_info *, \
    1725                         const Elf_Internal_Sym *, const char **, flagword *, \
    1726                         asection **, bfd_vma *)))               i370_noop
     1653  (bfd_boolean (*) \
     1654     PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *, \
     1655              const char **, flagword *, asection **, bfd_vma *))) i370_noop
    17271656#define elf_backend_finish_dynamic_symbol \
    1728   (boolean (*) PARAMS ((bfd *, struct bfd_link_info *, \
    1729                         struct elf_link_hash_entry *, \
    1730                         Elf_Internal_Sym *)))                   i370_noop
     1657  (bfd_boolean (*) \
     1658     PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *, \
     1659              Elf_Internal_Sym *))) i370_noop
    17311660#define elf_backend_additional_program_headers \
    1732   (int (*) PARAMS ((bfd *)))                                    i370_noop
     1661  (int (*) PARAMS ((bfd *))) i370_noop
    17331662#define elf_backend_modify_segment_map \
    1734   (boolean (*) PARAMS ((bfd *)))                                i370_noop
     1663  (bfd_boolean (*) PARAMS ((bfd *))) i370_noop
    17351664
    17361665#include "elf32-target.h"
Note: See TracChangeset for help on using the changeset viewer.