This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[PATCH] AIX5.1 for IA-64 fixes


The attached patch fixes some relocation errors on IA-64/AIX5.1 (aka
Monterey).

* bfd/elfxx-ia64.c: Put __GLOB_DATA_PTR into appropriate section (.bss
instead of .got) and avoid emitting empty relocations.
* ld/emulparams/elf64_aix.sh: Use page size and section addresses to
match IBM compiler output.

Index: bfd/elfxx-ia64.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-ia64.c,v
retrieving revision 1.16
diff -d -c -p -b -w -r1.16 elfxx-ia64.c
*** elfxx-ia64.c        2001/05/11 12:36:46     1.16
--- elfxx-ia64.c        2001/05/23 02:09:19
*************** elfNN_ia64_aix_add_symbol_hook (abfd, in
*** 1161,1170 ****
  {
    if (strcmp (*namep, "__GLOB_DATA_PTR") == 0)
      {
!       /* Define __GLOB_DATA_PTR.  This is expected to be a
linker-defined
!        symbol by the Aix C runtime startup code.  Define the symbol
!        when it is encountered.  IBM sez no one else should use it b/c
it is
!        undocumented.  */
        struct elf_link_hash_entry *h;

        h = (struct elf_link_hash_entry *) bfd_link_hash_lookup
(info->hash, *na
mep, false, false, false);
--- 1161,1169 ----
  {
    if (strcmp (*namep, "__GLOB_DATA_PTR") == 0)
      {
!       /* Define __GLOB_DATA_PTR when it is encountered.  This is
expected to
!        be a linker-defined symbol by the Aix C runtime startup code.
IBM sez
!        no one else should use it b/c it is undocumented.  */
        struct elf_link_hash_entry *h;

        h = (struct elf_link_hash_entry *) bfd_link_hash_lookup
(info->hash, *na
mep, false, false, false);
*************** elfNN_ia64_aix_add_symbol_hook (abfd, in
*** 1177,1183 ****
          ia64_info = elfNN_ia64_hash_table (info);

          if (!(_bfd_generic_link_add_one_symbol
!               (info, abfd, *namep, BSF_GLOBAL, ia64_info->got_sec,
                 bed->got_symbol_offset, (const char *) NULL, false,
                 bed->collect, (struct bfd_link_hash_entry **) &h)))
            return false;
--- 1176,1183 ----
          ia64_info = elfNN_ia64_hash_table (info);

          if (!(_bfd_generic_link_add_one_symbol
!               (info, abfd, *namep, BSF_GLOBAL,
!                bfd_get_section_by_name (abfd, ".bss"),
                 bed->got_symbol_offset, (const char *) NULL, false,
                 bed->collect, (struct bfd_link_hash_entry **) &h)))
            return false;
*************** elfNN_ia64_aix_add_symbol_hook (abfd, in
*** 1185,1192 ****
          h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
          h->type = STT_OBJECT;

!         if (info->shared
!             && ! _bfd_elf_link_record_dynamic_symbol (info, h))
            return false;
        }

--- 1185,1191 ----
          h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
          h->type = STT_OBJECT;

!         if (! _bfd_elf_link_record_dynamic_symbol (info, h))
            return false;
        }

*************** elfNN_ia64_aix_add_symbol_hook (abfd, in
*** 1198,1206 ****

        /* SHN_AIX_SYSCALL: Treat this as any other symbol.  The special
symbol
         is only relevant when compiling code for extended system calls.

!        Replace the "special" section with .text, if possible. */
!       /* FIXME need to determine the proper section instead of
defaulting to
!        .text.  */
        for (i = 1; i < elf_elfheader (abfd)->e_shnum; i++)
        {
          asection * sec = bfd_section_from_elf_index (abfd, i);
--- 1197,1204 ----

        /* SHN_AIX_SYSCALL: Treat this as any other symbol.  The special
symbol
         is only relevant when compiling code for extended system calls.

!        Replace the "special" section with .text, if possible.
!        Note that these symbols are always assumed to be in .text. */
        for (i = 1; i < elf_elfheader (abfd)->e_shnum; i++)
        {
          asection * sec = bfd_section_from_elf_index (abfd, i);
*************** elfNN_ia64_check_relocs (abfd, info, sec
*** 2019,2027 ****
        case R_IA64_FPTR32LSB:
        case R_IA64_FPTR64MSB:
        case R_IA64_FPTR64LSB:
!         if (elfNN_ia64_aix_vec (abfd->xvec))
!           need_entry = NEED_FPTR | NEED_DYNREL;
!         else if (info->shared || h)
            need_entry = NEED_FPTR | NEED_DYNREL;
          else
            need_entry = NEED_FPTR;
--- 2017,2023 ----
        case R_IA64_FPTR32LSB:
        case R_IA64_FPTR64MSB:
        case R_IA64_FPTR64LSB:
!         if (info->shared || h || elfNN_ia64_aix_vec (abfd->xvec))
            need_entry = NEED_FPTR | NEED_DYNREL;
          else
            need_entry = NEED_FPTR;
*************** elfNN_ia64_check_relocs (abfd, info, sec
*** 2071,2078 ****
        case R_IA64_DIR64LSB:
          /* Shared objects will always need at least a REL relocation.
*/
          if (info->shared || maybe_dynamic
-             /* On AIX, we always need a relocation, but make sure
-                __GLOB_DATA_PTR doesn't get an entry.  */
              || (elfNN_ia64_aix_vec (abfd->xvec)
                  && (!h || strcmp (h->root.root.string,
                                    "__GLOB_DATA_PTR") != 0)))
--- 2067,2072 ----
*************** allocate_global_data_got (dyn_i, data)
*** 2198,2204 ****
    if (dyn_i->want_got
        && ! dyn_i->want_fptr
        && (elfNN_ia64_dynamic_symbol_p (dyn_i->h, x->info)
!         || elfNN_ia64_aix_vec (x->info->hash->creator)))
       {
         dyn_i->got_offset = x->ofs;
         x->ofs += 8;
--- 2192,2200 ----
    if (dyn_i->want_got
        && ! dyn_i->want_fptr
        && (elfNN_ia64_dynamic_symbol_p (dyn_i->h, x->info)
!         || (elfNN_ia64_aix_vec (x->info->hash->creator)
!             && (!dyn_i->h || strcmp (dyn_i->h->root.root.string,
!                                      "__GLOB_DATA_PTR") != 0))))
       {
         dyn_i->got_offset = x->ofs;
         x->ofs += 8;
*************** allocate_dynrel_entries (dyn_i, data)
*** 2412,2418 ****

    ia64_info = elfNN_ia64_hash_table (x->info);
    dynamic_symbol = elfNN_ia64_dynamic_symbol_p (dyn_i->h, x->info)
!     || elfNN_ia64_aix_vec (x->info->hash->creator);
    shared = x->info->shared;

    /* Take care of the normal data relocations.  */
--- 2408,2417 ----

    ia64_info = elfNN_ia64_hash_table (x->info);
    dynamic_symbol = elfNN_ia64_dynamic_symbol_p (dyn_i->h, x->info)
!     || (elfNN_ia64_aix_vec (x->info->hash->creator)
!       /* Don't allocate an entry for __GLOB_DATA_PTR */
!       && (!dyn_i->h || strcmp (dyn_i->h->root.root.string,
!         "__GLOB_DATA_PTR") != 0));
    shared = x->info->shared;

    /* Take care of the normal data relocations.  */
*************** elfNN_ia64_relocate_section (output_bfd,
*** 3528,3538 ****
          /* Install a dynamic relocation for this reloc.  */
          if ((dynamic_symbol_p || info->shared
               || (elfNN_ia64_aix_vec (info->hash->creator)
!                  /* We want REL relocation for _GLOB_DATA_PTR, which
would
!                     otherwise be an IMM64, which isn't handled below.
The
!                     symbol comes from the C runtime.  */
!                  && (!h ||
!                      strcmp (h->root.root.string, "__GLOB_DATA_PTR")
!= 0)))
              && (input_section->flags & SEC_ALLOC) != 0)
            {
              unsigned int dyn_r_type;
--- 3527,3535 ----
          /* Install a dynamic relocation for this reloc.  */
          if ((dynamic_symbol_p || info->shared
               || (elfNN_ia64_aix_vec (info->hash->creator)
!                  /* Don't emit relocs for __GLOB_DATA_PTR on AIX. */
!                  && (!h || strcmp (h->root.root.string,
!                                    "__GLOB_DATA_PTR") != 0)))
              && (input_section->flags & SEC_ALLOC) != 0)
            {
              unsigned int dyn_r_type;

Index: ld/emulparams/elf64_aix.sh
===================================================================
RCS file: /cvs/src/src/ld/emulparams/elf64_aix.sh,v
retrieving revision 1.3
diff -d -c -p -b -w -r1.3 elf64_aix.sh
*** elf64_aix.sh        2001/05/11 12:36:47     1.3
--- elf64_aix.sh        2001/05/23 02:09:31
*************** TEMPLATE_NAME=elf32
*** 5,16 ****
  OUTPUT_FORMAT="elf64-ia64-aix-little"
  ARCH=ia64
  MACHINE=
! MAXPAGESIZE=0x1000
! TEXT_START_ADDR="0x100000000"
! DATA_ADDR="0x200000000 + (. & (${MAXPAGESIZE} - 1))"
  GENERATE_SHLIB_SCRIPT=yes
  NOP=0x00300000010070000002000001000400  # a bundle full of nops
- OTHER_GOT_SYMBOLS='. = ALIGN (8); PROVIDE (__gp = . + 0x200000);'
  OTHER_GOT_SECTIONS='.IA_64.pltoff : { *(.IA_64.pltoff) }'
  OTHER_PLT_RELOC_SECTIONS='.rela.IA_64.pltoff : { *(.rela.IA_64.pltoff)
}'
  OTHER_READONLY_SECTIONS='.opd : { *(.opd) }  .IA_64.unwind_info : {
*(.IA_64.u
nwind_info*) *(.gnu.linkonce.ia64unwi.*) }  .IA_64.unwind : {
*(.IA_64.unwind*)
*(.gnu.linkonce.ia64unw.*) }'
--- 5,15 ----
  OUTPUT_FORMAT="elf64-ia64-aix-little"
  ARCH=ia64
  MACHINE=
! MAXPAGESIZE=0x10000
! TEXT_START_ADDR="0x10000000"
! DATA_ADDR="0x20000000 + (. & (${MAXPAGESIZE} - 1))"
  GENERATE_SHLIB_SCRIPT=yes
  NOP=0x00300000010070000002000001000400  # a bundle full of nops
  OTHER_GOT_SECTIONS='.IA_64.pltoff : { *(.IA_64.pltoff) }'
  OTHER_PLT_RELOC_SECTIONS='.rela.IA_64.pltoff : { *(.rela.IA_64.pltoff)
}'
  OTHER_READONLY_SECTIONS='.opd : { *(.opd) }  .IA_64.unwind_info : {
*(.IA_64.u
nwind_info*) *(.gnu.linkonce.ia64unwi.*) }  .IA_64.unwind : {
*(.IA_64.unwind*)
*(.gnu.linkonce.ia64unw.*) }'



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]