This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: PATCH: ld/2537: Linker doesn't allow sections reserved for applications.
On Wed, Apr 19, 2006 at 07:13:31AM -0700, H. J. Lu wrote:
> On Wed, Apr 19, 2006 at 12:16:53AM -0400, Daniel Jacobowitz wrote:
> > On Wed, Apr 19, 2006 at 12:05:25PM +0930, Alan Modra wrote:
> > > Next question: What about SHT_LOPROC thru SHT_HIPROC that aren't handled
> > > by the backend function? And SHT_LOOS thru SHT_HIOS? I think you ought
> > > to be consistent about unknown section types in these ranges. ie. If
> > > SHT_LOUSER thru SHT_HIUSER is acceptable, then so should the others.
> >
> > It would be Really Really Nice if we could reject these as linker input
> > without (A) issuing useless error messages, which we currently (or
> > formerly?) did for unknown section types, and (B) rejecting them for
> > objdump.
> >
>
> This patch adds an error on all sections we don't know how to handle.
>
>
This patch should provide better error messages.
H.J.
----
2006-04-18 H.J. Lu <hongjiu.lu@intel.com>
PR ld/2537
* elf.c (bfd_section_from_shdr): Allow sections reserved for
applications. Issue an error on sections we don't know how
to handle.
--- bfd/elf.c.user 2006-04-14 14:45:19.000000000 -0700
+++ bfd/elf.c 2006-04-19 09:15:58.000000000 -0700
@@ -2158,9 +2158,49 @@ bfd_section_from_shdr (bfd *abfd, unsign
break;
default:
- /* Check for any processor-specific section types. */
- return bed->elf_backend_section_from_shdr (abfd, hdr, name,
- shindex);
+ {
+ const char *specific = "";
+
+ /* Check for any processor-specific section types. */
+ if (bed->elf_backend_section_from_shdr (abfd, hdr, name,
+ shindex))
+ return TRUE;
+
+ if (hdr->sh_type >= SHT_LOUSER && hdr->sh_type <= SHT_HIUSER)
+ {
+ if ((hdr->sh_flags & SHF_ALLOC) != 0)
+ {
+ /* FIXME: How to properly handle allocated section
+ reserved for applications? */
+ specific = " allocated, application specific";
+ goto unsupported;
+ }
+ else
+ /* Allow sections reserved for applications. */
+ return _bfd_elf_make_section_from_shdr (abfd, hdr,
+ name, shindex);
+ }
+ else if (hdr->sh_type >= SHT_LOPROC
+ && hdr->sh_type <= SHT_HIPROC)
+ {
+ specific = " processor specific";
+ goto unsupported;
+ }
+ else if (hdr->sh_type >= SHT_LOOS
+ && hdr->sh_type <= SHT_HIOS)
+ {
+ specific = " OS specific";
+ goto unsupported;
+ }
+
+unsupported:
+ /* FIXME: We should handle this section. */
+ (*_bfd_error_handler)
+ (_("%B: don't know how to handle%s section `%s' [0x%8x]"),
+ abfd, specific, name, hdr->sh_type);
+ }
+
+ return FALSE;
}
return TRUE;