OSDN Git Service

bfd/
authorJakub Jelinek <jakub@redhat.com>
Fri, 30 May 2003 15:50:11 +0000 (15:50 +0000)
committerJakub Jelinek <jakub@redhat.com>
Fri, 30 May 2003 15:50:11 +0000 (15:50 +0000)
* elflink.h (elf_link_add_object_symbols): Use !info->executable
instead of info->shared where appropriate.
(bfd_elfNN_size_dynamic_sections, elf_link_output_extsym): Likewise.
* elflink.c (_bfd_elf_create_got_section): Likewise.
(_bfd_elf_link_create_dynamic_sections): Likewise.
(_bfd_elf_link_assign_sym_version): Likewise.
* elf32-i386.c (elf_i386_size_dynamic_sections): Create .interp section
and DT_DEBUG dynamic tag even for position independent executables.
* elf32-ppc.c (ppc_elf_size_dynamic_sections): Likewise.
* elf32-s390.c (elf_s390_size_dynamic_sections: Likewise.
* elf64-ppc.c (ppc64_elf_size_dynamic_sections: Likewise.
* elf64-s390.c (elf_s390_size_dynamic_sections: Likewise.
* elf64-x86-64.c (elf64_x86_64_size_dynamic_sections: Likewise.
* elfxx-ia64.c (elfNN_ia64_size_dynamic_sections: Likewise.
* elf32-sparc.c (elf32_sparc_size_dynamic_sections: Likewise.
* elf64-alpha.c (elf64_alpha_size_dynamic_sections: Likewise.
* elf64-sparc.c (sparc64_elf_size_dynamic_sections: Likewise.
include/
* bfdlink.h (struct bfd_link_info): Add pie and executable
bits.
ld/
* lexsup.c (OPTION_PIE): Define.
(ld_options): Add -pie and --pic-executable options.
(parse_args): Handle OPTION_PIE.
* ldmain.c (main): Initialize link_info.pie and
link_info.executable.
* genscripts.sh: Generate PIE scripts.
* ld.texinfo: Document -pie and --pic-executable options.
* emultempl/elf32.em (gld${EMULATION_NAME}_after_open):
(gld${EMULATION_NAME}_place_orphan): Likewise.
(gld${EMULATION_NAME}_get_script): Include PIE scripts.
* scripttempl/elf.sc: In PIE scripts set . the same way as in
shared scripts.
* emulparams/elf_i386.sh (GENERATE_PIE_SCRIPT): Set to yes.
* emulparams/elf64_ia64.sh (GENERATE_PIE_SCRIPT): Likewise.
* emulparams/elf32ppc.sh (GENERATE_PIE_SCRIPT): Likewise.
* emulparams/elf64ppc.sh (GENERATE_PIE_SCRIPT): Likewise.
* emulparams/elf_x86_64.sh (GENERATE_PIE_SCRIPT): Likewise.
* emulparams/elf_s390.sh (GENERATE_PIE_SCRIPT): Likewise.
* emulparams/elf32_sparc.sh (GENERATE_PIE_SCRIPT): Likewise.
* emulparams/elf64_sparc.sh (GENERATE_PIE_SCRIPT): Likewise.
* emulparams/elf64alpha.sh (GENERATE_PIE_SCRIPT): Likewise.
* emulparams/elf64_s390.sh (GENERATE_PIE_SCRIPT): Likewise.
* emulparams/elf_i386.sh (GENERATE_PIE_SCRIPT): Likewise.

15 files changed:
bfd/ChangeLog
bfd/elf32-i386.c
bfd/elf32-ppc.c
bfd/elf32-s390.c
bfd/elf32-sparc.c
bfd/elf64-alpha.c
bfd/elf64-ppc.c
bfd/elf64-s390.c
bfd/elf64-sparc.c
bfd/elf64-x86-64.c
bfd/elflink.c
bfd/elflink.h
bfd/elfxx-ia64.c
include/ChangeLog
include/bfdlink.h

index aa1aeae..8eb1bfe 100644 (file)
@@ -1,3 +1,24 @@
+2003-05-30  Ulrich Drepper  <drepper@redhat.com>
+           Jakub Jelinek  <jakub@redhat.com>
+
+       * elflink.h (elf_link_add_object_symbols): Use !info->executable
+       instead of info->shared where appropriate.
+       (bfd_elfNN_size_dynamic_sections, elf_link_output_extsym): Likewise.
+       * elflink.c (_bfd_elf_create_got_section): Likewise.
+       (_bfd_elf_link_create_dynamic_sections): Likewise.
+       (_bfd_elf_link_assign_sym_version): Likewise.
+       * elf32-i386.c (elf_i386_size_dynamic_sections): Create .interp section
+       and DT_DEBUG dynamic tag even for position independent executables.
+       * elf32-ppc.c (ppc_elf_size_dynamic_sections): Likewise.
+       * elf32-s390.c (elf_s390_size_dynamic_sections: Likewise.
+       * elf64-ppc.c (ppc64_elf_size_dynamic_sections: Likewise.
+       * elf64-s390.c (elf_s390_size_dynamic_sections: Likewise.
+       * elf64-x86-64.c (elf64_x86_64_size_dynamic_sections: Likewise.
+       * elfxx-ia64.c (elfNN_ia64_size_dynamic_sections: Likewise.
+       * elf32-sparc.c (elf32_sparc_size_dynamic_sections: Likewise.
+       * elf64-alpha.c (elf64_alpha_size_dynamic_sections: Likewise.
+       * elf64-sparc.c (sparc64_elf_size_dynamic_sections: Likewise.
+
 2003-05-30  Kris Warkentin <kewarken@qnx.com>
 
        * elf.c (elfcore_grok_nto_status): Only set lwpid for the active or
index cfcb7b3..cd3dc9a 100644 (file)
@@ -1797,7 +1797,7 @@ elf_i386_size_dynamic_sections (output_bfd, info)
   if (htab->elf.dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
-      if (! info->shared)
+      if (info->executable)
        {
          s = bfd_get_section_by_name (dynobj, ".interp");
          if (s == NULL)
@@ -1963,7 +1963,7 @@ elf_i386_size_dynamic_sections (output_bfd, info)
 #define add_dynamic_entry(TAG, VAL) \
   bfd_elf32_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
 
-      if (! info->shared)
+      if (info->executable)
        {
          if (!add_dynamic_entry (DT_DEBUG, 0))
            return FALSE;
index 1e1ab8c..8c0e4d5 100644 (file)
@@ -2920,7 +2920,7 @@ ppc_elf_size_dynamic_sections (output_bfd, info)
   if (elf_hash_table (info)->dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
-      if (! info->shared)
+      if (info->executable)
        {
          s = bfd_get_section_by_name (htab->elf.dynobj, ".interp");
          BFD_ASSERT (s != NULL);
@@ -3102,7 +3102,7 @@ ppc_elf_size_dynamic_sections (output_bfd, info)
 #define add_dynamic_entry(TAG, VAL) \
   bfd_elf32_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
 
-      if (!info->shared)
+      if (info->executable)
        {
          if (!add_dynamic_entry (DT_DEBUG, 0))
            return FALSE;
index 9475f60..97be1db 100644 (file)
@@ -1927,7 +1927,7 @@ elf_s390_size_dynamic_sections (output_bfd, info)
   if (htab->elf.dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
-      if (! info->shared)
+      if (info->executable)
        {
          s = bfd_get_section_by_name (dynobj, ".interp");
          if (s == NULL)
@@ -2085,7 +2085,7 @@ elf_s390_size_dynamic_sections (output_bfd, info)
 #define add_dynamic_entry(TAG, VAL) \
   bfd_elf32_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
 
-      if (! info->shared)
+      if (info->executable)
        {
          if (!add_dynamic_entry (DT_DEBUG, 0))
            return FALSE;
index e2c6544..5f1bec5 100644 (file)
@@ -1820,7 +1820,7 @@ elf32_sparc_size_dynamic_sections (output_bfd, info)
   if (elf_hash_table (info)->dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
-      if (! info->shared)
+      if (info->executable)
        {
          s = bfd_get_section_by_name (dynobj, ".interp");
          BFD_ASSERT (s != NULL);
@@ -1997,7 +1997,7 @@ elf32_sparc_size_dynamic_sections (output_bfd, info)
 #define add_dynamic_entry(TAG, VAL) \
   bfd_elf32_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
 
-      if (!info->shared)
+      if (info->executable)
        {
          if (!add_dynamic_entry (DT_DEBUG, 0))
            return FALSE;
index 9ce3bf3..58ab6ba 100644 (file)
@@ -4090,7 +4090,7 @@ elf64_alpha_size_dynamic_sections (output_bfd, info)
   if (elf_hash_table (info)->dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
-      if (!info->shared)
+      if (info->executable)
        {
          s = bfd_get_section_by_name (dynobj, ".interp");
          BFD_ASSERT (s != NULL);
@@ -4176,7 +4176,7 @@ elf64_alpha_size_dynamic_sections (output_bfd, info)
 #define add_dynamic_entry(TAG, VAL) \
   bfd_elf64_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
 
-      if (!info->shared)
+      if (info->executable)
        {
          if (!add_dynamic_entry (DT_DEBUG, 0))
            return FALSE;
index f32d261..98af624 100644 (file)
@@ -5737,7 +5737,7 @@ ppc64_elf_size_dynamic_sections (output_bfd, info)
   if (htab->elf.dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
-      if (! info->shared)
+      if (info->executable)
        {
          s = bfd_get_section_by_name (dynobj, ".interp");
          if (s == NULL)
@@ -5936,7 +5936,7 @@ ppc64_elf_size_dynamic_sections (output_bfd, info)
 #define add_dynamic_entry(TAG, VAL) \
   bfd_elf64_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
 
-      if (!info->shared)
+      if (info->executable)
        {
          if (!add_dynamic_entry (DT_DEBUG, 0))
            return FALSE;
index 98555f2..b5d724a 100644 (file)
@@ -1898,7 +1898,7 @@ elf_s390_size_dynamic_sections (output_bfd, info)
   if (htab->elf.dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
-      if (! info->shared)
+      if (info->executable)
        {
          s = bfd_get_section_by_name (dynobj, ".interp");
          if (s == NULL)
@@ -2056,7 +2056,7 @@ elf_s390_size_dynamic_sections (output_bfd, info)
 #define add_dynamic_entry(TAG, VAL) \
   bfd_elf64_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
 
-      if (! info->shared)
+      if (info->executable)
        {
          if (!add_dynamic_entry (DT_DEBUG, 0))
            return FALSE;
index d7ad1b7..d25b429 100644 (file)
@@ -1781,7 +1781,7 @@ sparc64_elf_size_dynamic_sections (output_bfd, info)
   if (elf_hash_table (info)->dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
-      if (! info->shared)
+      if (info->executable)
        {
          s = bfd_get_section_by_name (dynobj, ".interp");
          BFD_ASSERT (s != NULL);
@@ -1880,7 +1880,7 @@ sparc64_elf_size_dynamic_sections (output_bfd, info)
       struct elf_strtab_hash *dynstr;
       struct elf_link_hash_table *eht = elf_hash_table (info);
 
-      if (!info->shared)
+      if (info->executable)
        {
          if (!add_dynamic_entry (DT_DEBUG, 0))
            return FALSE;
index c0ce57d..b39cdcd 100644 (file)
@@ -1618,7 +1618,7 @@ elf64_x86_64_size_dynamic_sections (output_bfd, info)
   if (htab->elf.dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
-      if (! info->shared)
+      if (info->executable)
        {
          s = bfd_get_section_by_name (dynobj, ".interp");
          if (s == NULL)
@@ -1779,7 +1779,7 @@ elf64_x86_64_size_dynamic_sections (output_bfd, info)
 #define add_dynamic_entry(TAG, VAL) \
   bfd_elf64_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
 
-      if (! info->shared)
+      if (info->executable)
        {
          if (!add_dynamic_entry (DT_DEBUG, 0))
            return FALSE;
index cc31186..d6f6d70 100644 (file)
@@ -94,7 +94,7 @@ _bfd_elf_create_got_section (abfd, info)
       h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
       h->type = STT_OBJECT;
 
-      if (info->shared
+      if (! info->executable
          && ! _bfd_elf_link_record_dynamic_symbol (info, h))
        return FALSE;
 
@@ -144,7 +144,7 @@ _bfd_elf_link_create_dynamic_sections (abfd, info)
 
   /* A dynamically linked executable has a .interp section, but a
      shared library does not.  */
-  if (! info->shared)
+  if (info->executable)
     {
       s = bfd_make_section (abfd, ".interp");
       if (s == NULL
@@ -227,7 +227,7 @@ _bfd_elf_link_create_dynamic_sections (abfd, info)
   h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
   h->type = STT_OBJECT;
 
-  if (info->shared
+  if (! info->executable
       && ! _bfd_elf_link_record_dynamic_symbol (info, h))
     return FALSE;
 
@@ -295,7 +295,7 @@ _bfd_elf_create_dynamic_sections (abfd, info)
       h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
       h->type = STT_OBJECT;
 
-      if (info->shared
+      if (! info->executable
          && ! _bfd_elf_link_record_dynamic_symbol (info, h))
        return FALSE;
     }
@@ -1760,7 +1760,7 @@ _bfd_elf_link_assign_sym_version (h, data)
 
       /* If we are building an application, we need to create a
         version node for this version.  */
-      if (t == NULL && ! info->shared)
+      if (t == NULL && info->executable)
        {
          struct bfd_elf_version_tree **pp;
          int version_index;
index 7b32491..e7019f3 100644 (file)
@@ -474,7 +474,7 @@ elf_link_add_object_symbols (abfd, info)
      .gnu.warning.SYMBOL are treated as warning symbols for the given
      symbol.  This differs from .gnu.warning sections, which generate
      warnings when they are included in an output file.  */
-  if (! info->shared)
+  if (info->executable)
     {
       asection *s;
 
@@ -1321,7 +1321,7 @@ elf_link_add_object_symbols (abfd, info)
                }
              else
                new_flag = ELF_LINK_HASH_DEF_REGULAR;
-             if (info->shared
+             if (! info->executable
                  || (old_flags & (ELF_LINK_HASH_DEF_DYNAMIC
                                   | ELF_LINK_HASH_REF_DYNAMIC)) != 0)
                dynsym = TRUE;
@@ -2174,7 +2174,7 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath,
       if (bfd_get_section_by_name (output_bfd, ".preinit_array") != NULL)
        {
          /* DT_PREINIT_ARRAY is not allowed in shared library.  */
-         if (info->shared)
+         if (! info->executable)
            {
              bfd *sub;
              asection *o;
@@ -2440,7 +2440,7 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath,
 
       if (info->flags_1)
        {
-         if (! info->shared)
+         if (info->executable)
            info->flags_1 &= ~ (DF_1_INITFIRST
                                | DF_1_NODELETE
                                | DF_1_NOOPEN);
@@ -4417,7 +4417,8 @@ elf_link_output_extsym (h, data)
      referenced by regular files, because we will already have issued
      warnings for them.  */
   if (! finfo->info->relocateable
-      && (! finfo->info->shared || ! finfo->info->allow_shlib_undefined)
+      && (finfo->info->executable
+         || ! finfo->info->allow_shlib_undefined)
       && h->root.type == bfd_link_hash_undefined
       && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) != 0
       && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR) == 0
index ab2ff21..37fc968 100644 (file)
@@ -2903,7 +2903,7 @@ elfNN_ia64_size_dynamic_sections (output_bfd, info)
 
   /* Set the contents of the .interp section to the interpreter.  */
   if (ia64_info->root.dynamic_sections_created
-      && !info->shared)
+      && info->executable)
     {
       sec = bfd_get_section_by_name (dynobj, ".interp");
       BFD_ASSERT (sec != NULL);
@@ -3078,7 +3078,7 @@ elfNN_ia64_size_dynamic_sections (output_bfd, info)
         later (in finish_dynamic_sections) but we must add the entries now
         so that we get the correct size for the .dynamic section.  */
 
-      if (!info->shared)
+      if (info->executable)
        {
          /* The DT_DEBUG entry is filled in by the dynamic linker and used
             by the debugger.  */
index 8dfa46f..41e67bc 100644 (file)
@@ -1,3 +1,9 @@
+2003-05-30  Ulrich Drepper  <drepper@redhat.com>
+           Jakub Jelinek  <jakub@redhat.com>
+
+       * bfdlink.h (struct bfd_link_info): Add pie and executable
+       bits.
+
 2003-05-21  Nick Clifton  <nickc@redhat.com>
 
        * bfdlink.h (struct bfd_link_hash_table): Fix typo in comment.
index 89d916e..61fcf96 100644 (file)
@@ -291,6 +291,12 @@ struct bfd_link_info
   /* TRUE if relaxation is being finalized.  */
   unsigned int relax_finalizing: 1;
 
+  /* TRUE if generating a position independent executable.  */
+  unsigned int pie: 1;
+
+  /* TRUE if generating an executable, position independent or not.  */
+  unsigned int executable : 1;
+
   /* Which symbols to strip.  */
   enum bfd_link_strip strip;