]> git.pld-linux.org Git - packages/crosssparc-binutils.git/commitdiff
- fix PR ld/2607 (linker doesn't recognize an ELF library). auto/th/crosssparc64-binutils-2_16_91_0_7-1
authorPaweł Sikora <pluto@pld-linux.org>
Wed, 10 May 2006 13:54:52 +0000 (13:54 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    binutils-elfcode.h.patch -> 1.1

binutils-elfcode.h.patch [new file with mode: 0644]

diff --git a/binutils-elfcode.h.patch b/binutils-elfcode.h.patch
new file mode 100644 (file)
index 0000000..92480be
--- /dev/null
@@ -0,0 +1,59 @@
+--- binutils-2.16.91.0.7/bfd/elfcode.h.orig    2005-12-20 23:43:55.000000000 +0100
++++ binutils-2.16.91.0.7/bfd/elfcode.h 2006-05-10 15:43:08.822548000 +0200
+@@ -458,6 +458,25 @@
+         && (x_ehdrp->e_ident[EI_MAG3] == ELFMAG3));
+ }
++/* Determines if a given section index is valid.  */
++
++static inline bfd_boolean
++valid_section_index_p (unsigned index, unsigned num_sections)
++{
++  /* Note: We allow SHN_UNDEF as a valid section index.  */
++  if (index < SHN_LORESERVE || index > SHN_HIRESERVE)
++    return index < num_sections;
++  
++  /* We disallow the use of reserved indcies, except for those
++     with OS or Application specific meaning.  The test make use
++     of the knowledge that:
++       SHN_LORESERVE == SHN_LOPROC
++     and
++       SHN_HIPROC == SHN_LOOS - 1  */
++  /* XXX - Should we allow SHN_XINDEX as a valid index here ?  */
++  return (index >= SHN_LOPROC && index <= SHN_HIOS);
++}
++
+ /* Check to see if the file associated with ABFD matches the target vector
+    that ABFD points to.
+@@ -711,17 +730,13 @@
+         elf_swap_shdr_in (abfd, &x_shdr, i_shdrp + shindex);
+         /* Sanity check sh_link and sh_info.  */
+-        if (i_shdrp[shindex].sh_link >= num_sec
+-            || (i_shdrp[shindex].sh_link >= SHN_LORESERVE
+-                && i_shdrp[shindex].sh_link <= SHN_HIRESERVE))
++        if (! valid_section_index_p (i_shdrp[shindex].sh_link, num_sec))
+           goto got_wrong_format_error;
+         if (((i_shdrp[shindex].sh_flags & SHF_INFO_LINK)
+              || i_shdrp[shindex].sh_type == SHT_RELA
+              || i_shdrp[shindex].sh_type == SHT_REL)
+-            && (i_shdrp[shindex].sh_info >= num_sec
+-                || (i_shdrp[shindex].sh_info >= SHN_LORESERVE
+-                    && i_shdrp[shindex].sh_info <= SHN_HIRESERVE)))
++            && ! valid_section_index_p (i_shdrp[shindex].sh_info, num_sec))
+           goto got_wrong_format_error;
+         /* If the section is loaded, but not page aligned, clear
+@@ -739,9 +754,7 @@
+   /* A further sanity check.  */
+   if (i_ehdrp->e_shnum != 0)
+     {
+-      if (i_ehdrp->e_shstrndx >= elf_numsections (abfd)
+-        || (i_ehdrp->e_shstrndx >= SHN_LORESERVE
+-            && i_ehdrp->e_shstrndx <= SHN_HIRESERVE))
++      if (! valid_section_index_p (i_ehdrp->e_shstrndx, elf_numsections (abfd)))
+       goto got_wrong_format_error;
+     }
+   else if (i_ehdrp->e_shstrndx != 0)
This page took 0.074474 seconds and 4 git commands to generate.