]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Add bfd_link_pde, and simplify some tests of link_info.type
authorAlan Modra <amodra@gmail.com>
Wed, 19 Aug 2015 02:27:40 +0000 (11:57 +0930)
committerAlan Modra <amodra@gmail.com>
Wed, 19 Aug 2015 03:21:06 +0000 (12:51 +0930)
include/
* bfdlink.h (bfd_link_pde): Define.
bfd/
* elf-s390-common.c: Simplify expressions using
bfd_linke_executable, bfd_link_pie and bfd_link_pic.
* elf32-arm.c: Likewise.
* elf32-bfin.c: Likewise.
* elf32-frv.c: Likewise.
* elf32-m68k.c: Likewise.
* elf32-nios2.c: Likewise.
* elf32-ppc.c: Likewise.
* elf32-s390.c: Likewise.
* elf32-sh.c: Likewise.
* elf64-alpha.c: Likewise.
* elf64-ppc.c: Likewise.
* elf64-s390.c: Likewise.
* elflink.c: Likewise.

16 files changed:
bfd/ChangeLog
bfd/elf-s390-common.c
bfd/elf32-arm.c
bfd/elf32-bfin.c
bfd/elf32-frv.c
bfd/elf32-m68k.c
bfd/elf32-nios2.c
bfd/elf32-ppc.c
bfd/elf32-s390.c
bfd/elf32-sh.c
bfd/elf64-alpha.c
bfd/elf64-ppc.c
bfd/elf64-s390.c
bfd/elflink.c
include/ChangeLog
include/bfdlink.h

index c0fbbe9401583d675831c8dd312b7948b9dd3a8e..bcbf7f9e286231e99d5ea94f243a2a244c666bac 100644 (file)
@@ -1,3 +1,20 @@
+2015-08-19  Alan Modra  <amodra@gmail.com>
+
+       * elf-s390-common.c: Simplify expressions using
+       bfd_linke_executable, bfd_link_pie and bfd_link_pic.
+       * elf32-arm.c: Likewise.
+       * elf32-bfin.c: Likewise.
+       * elf32-frv.c: Likewise.
+       * elf32-m68k.c: Likewise.
+       * elf32-nios2.c: Likewise.
+       * elf32-ppc.c: Likewise.
+       * elf32-s390.c: Likewise.
+       * elf32-sh.c: Likewise.
+       * elf64-alpha.c: Likewise.
+       * elf64-ppc.c: Likewise.
+       * elf64-s390.c: Likewise.
+       * elflink.c: Likewise.
+
 2015-08-18  Jiong Wang  <jiong.wang@arm.com>
 
        * elfnn-aarch64.c (aarch64_reloc_got_type): Delete useless check.
index 5c36ec8700f8bb629cd0772f28ac8e0dc9746500..6b5b17b1846da6ec8e56677eeb58c40f0360dc6e 100644 (file)
@@ -151,8 +151,7 @@ keep:
      point to the IPLT slot.  That way the referencing shared lib will
      always get the PLT slot address when resolving the respective
      R_390_GLOB_DAT/R_390_64 relocs on that symbol.  */
-  if (bfd_link_executable (info)
-      && !bfd_link_pic (info)
+  if (bfd_link_pde (info)
       && h->def_regular
       && h->ref_dynamic)
     {
@@ -187,7 +186,7 @@ keep:
   if (h->got.refcount <= 0
       || (bfd_link_pic (info)
          && (h->dynindx == -1 || h->forced_local))
-      || (bfd_link_executable (info) && bfd_link_pic (info))
+      || bfd_link_pie (info)
       || htab->sgot == NULL)
     {
       /* Use .got.iplt.  */
index bd4b5763cfbfc0f5d2c8ea9c2f9e503e171bcc3a..2e7d26dbc703be7c5966f6da97b9d224ffc067c2 100644 (file)
@@ -9881,7 +9881,7 @@ elf32_arm_final_link_relocate (reloc_howto_type *           howto,
       }
 
     case R_ARM_TLS_LE32:
-      if (bfd_link_pic (info) && !bfd_link_pie (info))
+      if (bfd_link_dll (info))
        {
          (*_bfd_error_handler)
            (_("%B(%A+0x%lx): R_ARM_TLS_LE32 relocation not permitted in shared object"),
index 49ef360bcdfd88709b15f5507d44a1eabf44241c..152134ee7b9b445d96818fcab2350ffd11795897 100644 (file)
@@ -2215,7 +2215,7 @@ _bfinfdpic_emit_got_relocs_plt_entries (struct bfinfdpic_relocs_info *entry,
       /* If we're linking an executable at a fixed address, we can
         omit the dynamic relocation as long as the symbol is local to
         this module.  */
-      if (bfd_link_executable (info) && !bfd_link_pic (info)
+      if (bfd_link_pde (info)
          && (entry->symndx != -1
              || BFINFDPIC_SYM_LOCAL (info, entry->d.h)))
        {
@@ -2270,7 +2270,7 @@ _bfinfdpic_emit_got_relocs_plt_entries (struct bfinfdpic_relocs_info *entry,
          if (entry->symndx == -1
              && ! BFINFDPIC_FUNCDESC_LOCAL (info, entry->d.h)
              && BFINFDPIC_SYM_LOCAL (info, entry->d.h)
-             && !(bfd_link_executable (info) && !bfd_link_pic (info)))
+             && !bfd_link_pde (info))
            {
              reloc = R_BFIN_FUNCDESC;
              idx = elf_section_data (entry->d.h->root.u.def.section
@@ -2306,7 +2306,7 @@ _bfinfdpic_emit_got_relocs_plt_entries (struct bfinfdpic_relocs_info *entry,
             dynamic symbol entry for the got section, so idx will be
             zero, which means we can and should compute the address
             of the private descriptor ourselves.  */
-         if (bfd_link_executable (info) && !bfd_link_pic (info)
+         if (bfd_link_pde (info)
              && (entry->symndx != -1
                  || BFINFDPIC_FUNCDESC_LOCAL (info, entry->d.h)))
            {
@@ -2369,7 +2369,7 @@ _bfinfdpic_emit_got_relocs_plt_entries (struct bfinfdpic_relocs_info *entry,
       /* If we're linking an executable at a fixed address, we can
         omit the dynamic relocation as long as the symbol is local to
         this module.  */
-      if (bfd_link_executable (info) && !bfd_link_pic (info)
+      if (bfd_link_pde (info)
          && (entry->symndx != -1 || BFINFDPIC_SYM_LOCAL (info, entry->d.h)))
        {
          if (sec)
@@ -2417,8 +2417,7 @@ _bfinfdpic_emit_got_relocs_plt_entries (struct bfinfdpic_relocs_info *entry,
 
       /* If we've omitted the dynamic relocation, just emit the fixed
         addresses of the symbol and of the local GOT base offset.  */
-      if (bfd_link_executable (info)
-         && !bfd_link_pic (info)
+      if (bfd_link_pde (info)
          && sec
          && sec->output_section)
        {
@@ -2834,8 +2833,7 @@ bfinfdpic_relocate_section (bfd * output_bfd,
                   section+offset.  */
                if (h && ! BFINFDPIC_FUNCDESC_LOCAL (info, h)
                    && BFINFDPIC_SYM_LOCAL (info, h)
-                   && !(bfd_link_executable (info)
-                        && !bfd_link_pic (info)))
+                   && !bfd_link_pde (info))
                  {
                    dynindx = elf_section_data (h->root.u.def.section
                                                ->output_section)->dynindx;
@@ -2872,7 +2870,7 @@ bfinfdpic_relocate_section (bfd * output_bfd,
                   dynamic symbol entry for the got section, so idx will
                   be zero, which means we can and should compute the
                   address of the private descriptor ourselves.  */
-               if (bfd_link_executable (info) && !bfd_link_pic (info)
+               if (bfd_link_pde (info)
                    && (!h || BFINFDPIC_FUNCDESC_LOCAL (info, h)))
                  {
                    bfd_vma offset;
@@ -2995,7 +2993,7 @@ bfinfdpic_relocate_section (bfd * output_bfd,
               can omit the dynamic relocation as long as the symbol
               is defined in the current link unit (which is implied
               by its output section not being NULL).  */
-           if (bfd_link_executable (info) && !bfd_link_pic (info)
+           if (bfd_link_pde (info)
                && (!h || BFINFDPIC_SYM_LOCAL (info, h)))
              {
                if (osec)
@@ -3075,7 +3073,7 @@ bfinfdpic_relocate_section (bfd * output_bfd,
                /* If we've omitted the dynamic relocation, just emit
                   the fixed addresses of the symbol and of the local
                   GOT base offset.  */
-               if (bfd_link_executable (info) && !bfd_link_pic (info)
+               if (bfd_link_pde (info)
                    && (!h || BFINFDPIC_SYM_LOCAL (info, h)))
                  bfd_put_32 (output_bfd,
                              bfinfdpic_got_section (info)->output_section->vma
@@ -3655,7 +3653,7 @@ _bfinfdpic_count_relocs_fixups (struct bfinfdpic_relocs_info *entry,
 {
   bfd_vma relocs = 0, fixups = 0;
 
-  if (!bfd_link_executable (dinfo->info) || bfd_link_pie (dinfo->info))
+  if (!bfd_link_pde (dinfo->info))
     relocs = entry->relocs32 + entry->relocsfd + entry->relocsfdv;
   else
     {
index b55a7ab4f0380902257fdf252ab4b43bc7ecb62d..fa12528b3d11ab9ed7a4d5d894f8b9c1a5e783a9 100644 (file)
@@ -1384,7 +1384,7 @@ _frvfdpic_emit_got_relocs_plt_entries (struct frvfdpic_relocs_info *entry,
       /* If we're linking an executable at a fixed address, we can
         omit the dynamic relocation as long as the symbol is local to
         this module.  */
-      if (bfd_link_executable (info) && !bfd_link_pic (info)
+      if (bfd_link_pde (info)
          && (entry->symndx != -1
              || FRVFDPIC_SYM_LOCAL (info, entry->d.h)))
        {
@@ -1439,7 +1439,7 @@ _frvfdpic_emit_got_relocs_plt_entries (struct frvfdpic_relocs_info *entry,
          if (entry->symndx == -1
              && ! FRVFDPIC_FUNCDESC_LOCAL (info, entry->d.h)
              && FRVFDPIC_SYM_LOCAL (info, entry->d.h)
-             && !(bfd_link_executable (info) && !bfd_link_pic (info)))
+             && !bfd_link_pde (info))
            {
              reloc = R_FRV_FUNCDESC;
              idx = elf_section_data (entry->d.h->root.u.def.section
@@ -1482,7 +1482,7 @@ _frvfdpic_emit_got_relocs_plt_entries (struct frvfdpic_relocs_info *entry,
             dynamic symbol entry for the got section, so idx will be
             zero, which means we can and should compute the address
             of the private descriptor ourselves.  */
-         if (bfd_link_executable (info) && !bfd_link_pic (info)
+         if (bfd_link_pde (info)
              && (entry->symndx != -1
                  || FRVFDPIC_FUNCDESC_LOCAL (info, entry->d.h)))
            {
@@ -1545,7 +1545,7 @@ _frvfdpic_emit_got_relocs_plt_entries (struct frvfdpic_relocs_info *entry,
       /* If we're linking an executable at a fixed address, we can
         omit the dynamic relocation as long as the symbol is local to
         this module.  */
-      if (bfd_link_executable (info) && !bfd_link_pic (info)
+      if (bfd_link_pde (info)
          && (entry->symndx != -1 || FRVFDPIC_SYM_LOCAL (info, entry->d.h)))
        {
          if (sec)
@@ -1593,8 +1593,7 @@ _frvfdpic_emit_got_relocs_plt_entries (struct frvfdpic_relocs_info *entry,
 
       /* If we've omitted the dynamic relocation, just emit the fixed
         addresses of the symbol and of the local GOT base offset.  */
-      if (bfd_link_executable (info)
-         && !bfd_link_pic (info)
+      if (bfd_link_pde (info)
          && sec
          && sec->output_section)
        {
@@ -1847,7 +1846,7 @@ _frvfdpic_emit_got_relocs_plt_entries (struct frvfdpic_relocs_info *entry,
       if (bfd_link_executable (info) && ! entry->tlsoff_entry)
        entry->tlsoff_entry = entry->tlsdesc_entry + 4;
 
-      if (bfd_link_executable (info) && !bfd_link_pic (info)
+      if (bfd_link_pde (info)
          && ((idx == 0
               && (bfd_is_abs_section (sec)
                   || bfd_is_und_section (sec)))
@@ -3523,8 +3522,7 @@ elf32_frv_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
                   section+offset.  */
                if (h && ! FRVFDPIC_FUNCDESC_LOCAL (info, h)
                    && FRVFDPIC_SYM_LOCAL (info, h)
-                   && !(bfd_link_executable (info)
-                        && !bfd_link_pic (info)))
+                   && !bfd_link_pde (info))
                  {
                    dynindx = elf_section_data (h->root.u.def.section
                                                ->output_section)->dynindx;
@@ -3562,7 +3560,7 @@ elf32_frv_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
                   dynamic symbol entry for the got section, so idx will
                   be zero, which means we can and should compute the
                   address of the private descriptor ourselves.  */
-               if (bfd_link_executable (info) && !bfd_link_pic (info)
+               if (bfd_link_pde (info)
                    && (!h || FRVFDPIC_FUNCDESC_LOCAL (info, h)))
                  {
                    addend += frvfdpic_got_section (info)->output_section->vma;
@@ -3684,7 +3682,7 @@ elf32_frv_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
               can omit the dynamic relocation as long as the symbol
               is defined in the current link unit (which is implied
               by its output section not being NULL).  */
-           if (bfd_link_executable (info) && !bfd_link_pic (info)
+           if (bfd_link_pde (info)
                && (!h || FRVFDPIC_SYM_LOCAL (info, h)))
              {
                if (osec)
@@ -3773,7 +3771,7 @@ elf32_frv_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
                /* If we've omitted the dynamic relocation, just emit
                   the fixed addresses of the symbol and of the local
                   GOT base offset.  */
-               if (bfd_link_executable (info) && !bfd_link_pic (info)
+               if (bfd_link_pde (info)
                    && (!h || FRVFDPIC_SYM_LOCAL (info, h)))
                  bfd_put_32 (output_bfd,
                              frvfdpic_got_section (info)->output_section->vma
@@ -4512,7 +4510,7 @@ _frvfdpic_count_relocs_fixups (struct frvfdpic_relocs_info *entry,
 {
   bfd_vma relocs = 0, fixups = 0, tlsrets = 0;
 
-  if (!bfd_link_executable (dinfo->info) || bfd_link_pie (dinfo->info))
+  if (!bfd_link_pde (dinfo->info))
     {
       relocs = entry->relocs32 + entry->relocsfd + entry->relocsfdv
        + entry->relocstlsd;
index 10d2fcb286d7ec8f07e6ce5b41319683dfbb803b..f807e03741acfbd194c701ca4dc2fa7e3da7740a 100644 (file)
@@ -3916,7 +3916,7 @@ elf_m68k_relocate_section (bfd *output_bfd,
        case R_68K_TLS_LE32:
        case R_68K_TLS_LE16:
        case R_68K_TLS_LE8:
-         if (bfd_link_pic (info) && !bfd_link_pie (info))
+         if (bfd_link_dll (info))
            {
              (*_bfd_error_handler)
                (_("%B(%A+0x%lx): R_68K_TLS_LE32 relocation not permitted "
index fd70007b7ecb9a7096eca2136d1c8a185999ee8d..6a72f71f070a2ba928b78ff85e37656a4780e57b 100644 (file)
@@ -4352,7 +4352,7 @@ nios2_elf32_relocate_section (bfd *output_bfd,
 
              break;
            case R_NIOS2_TLS_LE16:
-             if (bfd_link_pic (info) && !bfd_link_pie (info))
+             if (bfd_link_dll (info))
                {
                  (*_bfd_error_handler)
                    (_("%B(%A+0x%lx): R_NIOS2_TLS_LE16 relocation not "
index 8415f1ece2b8a6f72299e7e219372c8ca2b0caae..3f708cb171369a8962c42a11a11c06c2e03a25d8 100644 (file)
@@ -5204,7 +5204,7 @@ ppc_elf_tls_optimize (bfd *obfd ATTRIBUTE_UNUSED,
   struct ppc_elf_link_hash_table *htab;
   int pass;
 
-  if (bfd_link_relocatable (info) || !bfd_link_executable (info))
+  if (!bfd_link_executable (info))
     return TRUE;
 
   htab = ppc_elf_hash_table (info);
@@ -6947,7 +6947,6 @@ ppc_elf_relax_section (bfd *abfd,
                 optimise away the call.  We won't be needing a long-
                 branch stub in that case.  */
              if (bfd_link_executable (link_info)
-                 && !bfd_link_relocatable (link_info)
                  && h == htab->tls_get_addr
                  && irel != internal_relocs)
                {
index de37ca46cc5f69de14b811c1cb461785d4ca2229..96c1531e7df0c291c0233c009f8f29861389a998 100644 (file)
@@ -3116,7 +3116,7 @@ elf_s390_relocate_section (bfd *output_bfd,
          break;
 
        case R_390_TLS_LE32:
-         if (bfd_link_pic (info) && !bfd_link_pie (info))
+         if (bfd_link_dll (info))
            {
              /* Linking a shared library with non-fpic code requires
                 a R_390_TLS_TPOFF relocation.  */
index 012ee4e6e9fd833802327d50bcdd8d44a239caba..7b8d7636de5fe4ce169eacbeb876ab7d741df798 100644 (file)
@@ -5440,7 +5440,7 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
 
            check_segment[0] = check_segment[1] = -1;
 
-           if (! bfd_link_pic (info) || bfd_link_pie (info))
+           if (!bfd_link_dll (info))
              {
                relocation = tpoff (info, relocation);
                addend = rel->r_addend;
@@ -6542,7 +6542,7 @@ sh_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec,
          break;
 
        case R_SH_TLS_LE_32:
-         if (bfd_link_pic (info) && !bfd_link_pie (info))
+         if (bfd_link_dll (info))
            {
              (*_bfd_error_handler)
                (_("%B: TLS local exec code cannot be linked into shared objects"),
index f67b0afb0485cd736cb773ffecf6eff49e59a204..df19da7c7a9367cfba051c3ff39f1fbd978ee621 100644 (file)
@@ -1896,7 +1896,7 @@ elf64_alpha_check_relocs (bfd *abfd, struct bfd_link_info *info,
          break;
 
        case R_ALPHA_TPREL64:
-         if (bfd_link_pic (info) && !bfd_link_pie (info))
+         if (bfd_link_dll (info))
            {
              info->flags |= DF_STATIC_TLS;
              need = NEED_DYNREL;
@@ -2742,7 +2742,8 @@ elf64_alpha_calc_dynrel_sizes (struct alpha_elf_link_hash_entry *h,
   for (relent = h->reloc_entries; relent; relent = relent->next)
     {
       entries = alpha_dynamic_entries_for_reloc (relent->rtype, dynamic,
-                                                bfd_link_pic (info), bfd_link_pie (info));
+                                                bfd_link_pic (info),
+                                                bfd_link_pie (info));
       if (entries)
        {
          relent->srel->size +=
@@ -3071,8 +3072,7 @@ elf64_alpha_relax_got_load (struct alpha_relax_info *info, bfd_vma symval,
 
   /* Can't use local-exec relocations in shared libraries.  */
   if (r_type == R_ALPHA_GOTTPREL
-      && (bfd_link_pic (info->link_info)
-         && !bfd_link_pie (info->link_info)))
+      && bfd_link_dll (info->link_info))
     return TRUE;
 
   if (r_type == R_ALPHA_LITERAL)
@@ -4586,7 +4586,7 @@ elf64_alpha_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
            else if (r_type == R_ALPHA_TPREL64)
              {
                BFD_ASSERT (elf_hash_table (info)->tls_sec != NULL);
-               if (!bfd_link_pic (info) || bfd_link_pie (info))
+               if (!bfd_link_dll (info))
                  {
                    value -= tp_base;
                    goto default_reloc;
@@ -4636,7 +4636,7 @@ elf64_alpha_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
                  input_bfd, h->root.root.root.string);
               ret_val = FALSE;
             }
-         else if ((bfd_link_pic (info) || bfd_link_pie (info))
+         else if (bfd_link_pic (info)
                   && undef_weak_ref)
             {
               (*_bfd_error_handler)
@@ -4718,7 +4718,7 @@ elf64_alpha_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
        case R_ALPHA_TPRELHI:
        case R_ALPHA_TPRELLO:
        case R_ALPHA_TPREL16:
-         if (bfd_link_pic (info) && !bfd_link_pie (info))
+         if (bfd_link_dll (info))
            {
              (*_bfd_error_handler)
                (_("%B: TLS local exec code cannot be linked into shared objects"),
index 8cff9903053a747df5e988098d236004e3b75c0f..3e8bd33db1e7e1615a969df7327f658bf5c7d8ee 100644 (file)
@@ -8184,7 +8184,7 @@ ppc64_elf_tls_optimize (struct bfd_link_info *info)
   unsigned char *toc_ref;
   int pass;
 
-  if (bfd_link_relocatable (info) || !bfd_link_executable (info))
+  if (!bfd_link_executable (info))
     return TRUE;
 
   htab = ppc_hash_table (info);
index 2e505f3389927df280dd447f4eb758cfbb8edfca..0264236f2a5ae7a075bc66b77323858f5db03b3e 100644 (file)
@@ -3082,7 +3082,7 @@ elf_s390_relocate_section (bfd *output_bfd,
          break;
 
        case R_390_TLS_LE64:
-         if (bfd_link_pic (info) && !bfd_link_pie (info))
+         if (bfd_link_dll (info))
            {
              /* Linking a shared library with non-fpic code requires
                 a R_390_TLS_TPOFF relocation.  */
index 7f042711e7fb15f5c8e92268fabf1df4bbee9d73..76f6493e3af4d21982684f6c45d5748671a6f805 100644 (file)
@@ -633,7 +633,7 @@ bfd_elf_record_link_assignment (bfd *output_bfd,
   if ((h->def_dynamic
        || h->ref_dynamic
        || bfd_link_pic (info)
-       || (bfd_link_executable (info)
+       || (bfd_link_pde (info)
           && elf_hash_table (info)->is_relocatable_executable))
       && h->dynindx == -1)
     {
index e1bd6aed715166d240657ac7fea793223308d79f..5197abfffd0263eb03988a68e6c905c0f4606234 100644 (file)
@@ -1,3 +1,7 @@
+2015-08-19  Alan Modra  <amodra@gmail.com>
+
+       * bfdlink.h (bfd_link_pde): Define.
+
 2015-08-18  H.J. Lu  <hongjiu.lu@intel.com>
 
        * include/bfdlink.h (output_type): New enum.
index 797a4650e85a6f587e3c9deb4327f01174328764..62309a5c6827e2798dec3b9ce91e758691baaabe 100644 (file)
@@ -274,6 +274,8 @@ enum output_type
 #define bfd_link_pic(info)        (info)->pic
 #define bfd_link_pie(info)        (bfd_link_executable (info) \
                                    && bfd_link_pic (info))
+#define bfd_link_pde(info)        (bfd_link_executable (info) \
+                                   && !bfd_link_pic (info))
 
 /* This structure holds all the information needed to communicate
    between BFD and the linker when doing a link.  */