(SEC_HAS_GOT_REF): Define new flag for asection.
authorAlan Modra <amodra@gmail.com>
Tue, 5 Sep 2000 02:42:16 +0000 (02:42 +0000)
committerAlan Modra <amodra@gmail.com>
Tue, 5 Sep 2000 02:42:16 +0000 (02:42 +0000)
(bfd_get_unique_section_name): New function.

bfd/ChangeLog
bfd/bfd-in2.h
bfd/section.c

index cae91298a4e22e091feec4b6255b14200949d70e..ab44781912eaba6a763c3188031f11a916ca6f52 100644 (file)
@@ -1,5 +1,9 @@
 2000-09-05  Alan Modra  <alan@linuxcare.com.au>
 
+       * section.c (SEC_HAS_GOT_REF): Define new flag for asection.
+       (bfd_get_unique_section_name): New function.
+       * bfd_in2.h: Regenerate.
+
        * elf64-hppa.c (elf64_hppa_check_relocs): Handle R_PARISC_PCREL12F.
        (elf64_hppa_size_dynamic_sections): Remove the FIXME at bfd_zalloc
        comment.
index 688a40d80151347b6ca462085556fea97b9dd1e2..66081e8f3965a7c36c418b137c9ca939eea4387b 100644 (file)
@@ -1008,6 +1008,14 @@ typedef struct sec
      sections.  */
 #define SEC_COFF_SHARED_LIBRARY 0x800
 
+  /* The section has GOT references.  This flag is only for the
+     linker, and is currently only used by the elf32-hppa back end.
+     It will be set if global offset table references were detected
+     in this section, which indicate to the linker that the section
+     contains PIC code, and must be handled specially when doing a
+     static link.  */
+#define SEC_HAS_GOT_REF 0x4000
+
   /* The section contains common symbols (symbols may be defined
      multiple times, the value of a symbol is the amount of
      space it requires, and the largest symbol value is the one
@@ -1274,6 +1282,11 @@ extern const struct symbol_cache_entry * const bfd_ind_symbol;
 asection *
 bfd_get_section_by_name PARAMS ((bfd *abfd, const char *name));
 
+char *
+bfd_get_unique_section_name PARAMS ((bfd *abfd,
+    const char *template,
+    int *count));
+
 asection *
 bfd_make_section_old_way PARAMS ((bfd *abfd, const char *name));
 
@@ -2024,11 +2037,6 @@ to compensate for the borrow when the low bits are added. */
   BFD_RELOC_MIPS_GOT_PAGE,
   BFD_RELOC_MIPS_GOT_OFST,
   BFD_RELOC_MIPS_GOT_DISP,
-  BFD_RELOC_SH_COPY,
-  BFD_RELOC_SH_GLOB_DAT,
-  BFD_RELOC_SH_JMP_SLOT,
-  BFD_RELOC_SH_RELATIVE,
-  BFD_RELOC_SH_GOTPC,
 
 
 /* i386/elf relocations */
@@ -2167,6 +2175,11 @@ field in the instruction. */
   BFD_RELOC_SH_LABEL,
   BFD_RELOC_SH_LOOP_START,
   BFD_RELOC_SH_LOOP_END,
+  BFD_RELOC_SH_COPY,
+  BFD_RELOC_SH_GLOB_DAT,
+  BFD_RELOC_SH_JMP_SLOT,
+  BFD_RELOC_SH_RELATIVE,
+  BFD_RELOC_SH_GOTPC,
 
 /* Thumb 23-, 12- and 9-bit pc-relative branches.  The lowest bit must
 be zero and is not stored in the instruction. */
index b9a39b6ac3866450ad651adc0c0cab2078c1aeb7..69d80cfb5eb4e63729be71c92c6622410c44691c 100644 (file)
@@ -264,6 +264,14 @@ CODE_FRAGMENT
 .     sections.  *}
 .#define SEC_COFF_SHARED_LIBRARY 0x800
 .
+.  {* The section has GOT references.  This flag is only for the
+.     linker, and is currently only used by the elf32-hppa back end.
+.     It will be set if global offset table references were detected
+.     in this section, which indicate to the linker that the section
+.     contains PIC code, and must be handled specially when doing a
+.     static link.  *}
+.#define SEC_HAS_GOT_REF 0x4000
+.
 .  {* The section contains common symbols (symbols may be defined
 .     multiple times, the value of a symbol is the amount of
 .     space it requires, and the largest symbol value is the one
@@ -635,6 +643,55 @@ bfd_get_section_by_name (abfd, name)
 }
 
 
+/*
+FUNCTION
+       bfd_get_unique_section_name
+
+SYNOPSIS
+       char *bfd_get_unique_section_name(bfd *abfd,
+                                         const char *template,
+                                         int *count);
+
+DESCRIPTION
+       Invent a section name that is unique in @var{abfd} by tacking
+       a digit suffix onto the original @var{template}.  If @var{count}
+       is non-NULL, then it specifies the first number tried as a
+       suffix to generate a unique name.  The value pointed to by
+       @var{count} will be incremented in this case.
+*/
+
+char *
+bfd_get_unique_section_name (abfd, template, count)
+     bfd *abfd;
+     const char *template;
+     int *count;
+{
+  int num;
+  unsigned int len;
+  char *sname;
+
+  len = strlen (template);
+  sname = bfd_malloc (len + 7);
+  strcpy (sname, template);
+  num = 1;
+  if (count != NULL)
+    num = *count;
+
+  do
+    {
+      /* If we have a million sections, something is badly wrong.  */
+      if (num > 999999)
+       abort ();
+      sprintf (sname + len, "%d", num++);
+    }
+  while (bfd_get_section_by_name (abfd, sname) != NULL);
+
+  if (count != NULL)
+    *count = num;
+  return sname;
+}
+
+
 /*
 FUNCTION
        bfd_make_section_old_way
This page took 0.034718 seconds and 4 git commands to generate.