public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* PATCH: ld/2537: Linker doesn't allow sections reserved for applications.
@ 2006-04-15  0:08 H. J. Lu
  2006-04-18 16:03 ` H. J. Lu
  0 siblings, 1 reply; 23+ messages in thread
From: H. J. Lu @ 2006-04-15  0:08 UTC (permalink / raw)
  To: binutils

Sections bewteen SHT_LOUSER and SHT_HIUSER are reserved for
applications. Linker should accept them.


H.J.
---
2006-04-14  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/2537
	* elf.c (bfd_section_from_shdr): Allow sections reserved for
	applications.

--- bfd/elf.c.user	2006-04-14 14:45:19.000000000 -0700
+++ bfd/elf.c	2006-04-14 16:25:24.000000000 -0700
@@ -2158,8 +2158,13 @@ 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,
+      if (hdr->sh_type >= SHT_LOUSER && hdr->sh_type <= SHT_HIUSER)
+	/* Allow sections reserved for applications.  */
+	return _bfd_elf_make_section_from_shdr (abfd, hdr, name,
+						shindex);
+      else
+	/* Check for any processor-specific section types.  */
+	return bed->elf_backend_section_from_shdr (abfd, hdr, name,
 						 shindex);
     }
 

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: PATCH: ld/2537: Linker doesn't allow sections reserved for applications.
  2006-04-15  0:08 PATCH: ld/2537: Linker doesn't allow sections reserved for applications H. J. Lu
@ 2006-04-18 16:03 ` H. J. Lu
  2006-04-18 17:26   ` Nick Clifton
  2006-04-19  0:13   ` Alan Modra
  0 siblings, 2 replies; 23+ messages in thread
From: H. J. Lu @ 2006-04-18 16:03 UTC (permalink / raw)
  To: binutils

On Fri, Apr 14, 2006 at 04:26:05PM -0700, H. J. Lu wrote:
> Sections bewteen SHT_LOUSER and SHT_HIUSER are reserved for
> applications. Linker should accept them.
> 
> 

Here is the updated patch. If section reserved for applications has
SHF_ALLOC, linker can't handle it properly.


H.J.
----
2006-04-14  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/2537
	* elf.c (bfd_section_from_shdr): Allow sections reserved for
	applications.

--- bfd/elf.c.user	2006-04-14 14:45:19.000000000 -0700
+++ bfd/elf.c	2006-04-17 09:42:46.000000000 -0700
@@ -2158,8 +2158,25 @@ 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,
+      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?  */
+	      (*_bfd_error_handler)
+	       (_("%B: allocated section `%s' reserved for applications"),
+		abfd, name);
+	      return FALSE;
+	    }
+	  else
+	    /* Allow sections reserved for applications.  */
+	    return _bfd_elf_make_section_from_shdr (abfd, hdr, name,
+						    shindex);
+	}
+      else
+	/* Check for any processor-specific section types.  */
+	return bed->elf_backend_section_from_shdr (abfd, hdr, name,
 						 shindex);
     }
 

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: PATCH: ld/2537: Linker doesn't allow sections reserved for applications.
  2006-04-18 16:03 ` H. J. Lu
@ 2006-04-18 17:26   ` Nick Clifton
  2006-04-18 20:37     ` H. J. Lu
  2006-04-19  0:13   ` Alan Modra
  1 sibling, 1 reply; 23+ messages in thread
From: Nick Clifton @ 2006-04-18 17:26 UTC (permalink / raw)
  To: H. J. Lu; +Cc: binutils

Hi H.J,

> +	      /* FIXME: How to properly handle allocated section
> +		 reserved for applications?  */
> +	      (*_bfd_error_handler)
> +	       (_("%B: allocated section `%s' reserved for applications"),

I think that the error message ought to be more helpful here.  Something 
along the lines of:

  "BFD library does not know how to handle the allocated, application
   specific section %s".

Also, it may be possible for a particular backend to handle such a 
section, so we ought to give elf_backend_section_from_shdr() a chance to 
process it, don't you think ?

Cheers
   Nick

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: PATCH: ld/2537: Linker doesn't allow sections reserved for applications.
  2006-04-18 17:26   ` Nick Clifton
@ 2006-04-18 20:37     ` H. J. Lu
  0 siblings, 0 replies; 23+ messages in thread
From: H. J. Lu @ 2006-04-18 20:37 UTC (permalink / raw)
  To: Nick Clifton; +Cc: binutils

On Tue, Apr 18, 2006 at 05:49:09PM +0100, Nick Clifton wrote:
> Hi H.J,
> 
> >+	      /* FIXME: How to properly handle allocated section
> >+		 reserved for applications?  */
> >+	      (*_bfd_error_handler)
> >+	       (_("%B: allocated section `%s' reserved for applications"),
> 
> I think that the error message ought to be more helpful here.  Something 
> along the lines of:
> 
>  "BFD library does not know how to handle the allocated, application
>   specific section %s".
> 
> Also, it may be possible for a particular backend to handle such a 
> section, so we ought to give elf_backend_section_from_shdr() a chance to 
> process it, don't you think ?

Like this?


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.

--- bfd/elf.c.user	2006-04-14 14:45:19.000000000 -0700
+++ bfd/elf.c	2006-04-18 10:23:01.000000000 -0700
@@ -2159,8 +2159,29 @@ bfd_section_from_shdr (bfd *abfd, unsign
 
     default:
       /* Check for any processor-specific section types.  */
-      return bed->elf_backend_section_from_shdr (abfd, hdr, name,
-						 shindex);
+      if (bed->elf_backend_section_from_shdr (abfd, hdr, name,
+					      shindex) == TRUE)
+	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?  */
+	      (*_bfd_error_handler)
+	       (_("%B: don't know how to handle allocated, application"
+		  " specific section `%s'"),
+		abfd, name);
+	      return FALSE;
+	    }
+	  else
+	    /* Allow sections reserved for applications.  */
+	    return _bfd_elf_make_section_from_shdr (abfd, hdr, name,
+						    shindex);
+	}
+
+      return FALSE;
     }
 
   return TRUE;

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: PATCH: ld/2537: Linker doesn't allow sections reserved for applications.
  2006-04-18 16:03 ` H. J. Lu
  2006-04-18 17:26   ` Nick Clifton
@ 2006-04-19  0:13   ` Alan Modra
  2006-04-19  0:33     ` H. J. Lu
  1 sibling, 1 reply; 23+ messages in thread
From: Alan Modra @ 2006-04-19  0:13 UTC (permalink / raw)
  To: H. J. Lu; +Cc: binutils

On Tue, Apr 18, 2006 at 09:01:10AM -0700, H. J. Lu wrote:
> Here is the updated patch. If section reserved for applications has
> SHF_ALLOC, linker can't handle it properly.

I'm curious.  Why doesn't the linker do what you expect?

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: PATCH: ld/2537: Linker doesn't allow sections reserved for applications.
  2006-04-19  0:13   ` Alan Modra
@ 2006-04-19  0:33     ` H. J. Lu
  2006-04-19  1:54       ` Alan Modra
  0 siblings, 1 reply; 23+ messages in thread
From: H. J. Lu @ 2006-04-19  0:33 UTC (permalink / raw)
  To: binutils

On Wed, Apr 19, 2006 at 09:20:16AM +0930, Alan Modra wrote:
> On Tue, Apr 18, 2006 at 09:01:10AM -0700, H. J. Lu wrote:
> > Here is the updated patch. If section reserved for applications has
> > SHF_ALLOC, linker can't handle it properly.
> 
> I'm curious.  Why doesn't the linker do what you expect?

It is not what I expect. It is I don't know what applications will
expect.


H.J.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: PATCH: ld/2537: Linker doesn't allow sections reserved for applications.
  2006-04-19  0:33     ` H. J. Lu
@ 2006-04-19  1:54       ` Alan Modra
  2006-04-19  2:09         ` H. J. Lu
  0 siblings, 1 reply; 23+ messages in thread
From: Alan Modra @ 2006-04-19  1:54 UTC (permalink / raw)
  To: H. J. Lu; +Cc: binutils

On Tue, Apr 18, 2006 at 05:13:19PM -0700, H. J. Lu wrote:
> On Wed, Apr 19, 2006 at 09:20:16AM +0930, Alan Modra wrote:
> > On Tue, Apr 18, 2006 at 09:01:10AM -0700, H. J. Lu wrote:
> > > Here is the updated patch. If section reserved for applications has
> > > SHF_ALLOC, linker can't handle it properly.
> > 
> > I'm curious.  Why doesn't the linker do what you expect?
> 
> It is not what I expect. It is I don't know what applications will
> expect.

Why is this any different for non-SHF_ALLOC sections?

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: PATCH: ld/2537: Linker doesn't allow sections reserved for applications.
  2006-04-19  1:54       ` Alan Modra
@ 2006-04-19  2:09         ` H. J. Lu
  2006-04-19  4:11           ` Alan Modra
  0 siblings, 1 reply; 23+ messages in thread
From: H. J. Lu @ 2006-04-19  2:09 UTC (permalink / raw)
  To: binutils

On Wed, Apr 19, 2006 at 10:03:39AM +0930, Alan Modra wrote:
> On Tue, Apr 18, 2006 at 05:13:19PM -0700, H. J. Lu wrote:
> > On Wed, Apr 19, 2006 at 09:20:16AM +0930, Alan Modra wrote:
> > > On Tue, Apr 18, 2006 at 09:01:10AM -0700, H. J. Lu wrote:
> > > > Here is the updated patch. If section reserved for applications has
> > > > SHF_ALLOC, linker can't handle it properly.
> > > 
> > > I'm curious.  Why doesn't the linker do what you expect?
> > 
> > It is not what I expect. It is I don't know what applications will
> > expect.
> 
> Why is this any different for non-SHF_ALLOC sections?

non-SHF_ALLOC sections won't be the parts of image. We don't need to
put them in segments. We can leave them as is without changing the
final image.


H.J.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: PATCH: ld/2537: Linker doesn't allow sections reserved for applications.
  2006-04-19  2:09         ` H. J. Lu
@ 2006-04-19  4:11           ` Alan Modra
  2006-04-19  4:16             ` H. J. Lu
  2006-04-19  5:59             ` Daniel Jacobowitz
  0 siblings, 2 replies; 23+ messages in thread
From: Alan Modra @ 2006-04-19  4:11 UTC (permalink / raw)
  To: H. J. Lu; +Cc: binutils

On Tue, Apr 18, 2006 at 07:01:46PM -0700, H. J. Lu wrote:
> On Wed, Apr 19, 2006 at 10:03:39AM +0930, Alan Modra wrote:
> > On Tue, Apr 18, 2006 at 05:13:19PM -0700, H. J. Lu wrote:
> > > On Wed, Apr 19, 2006 at 09:20:16AM +0930, Alan Modra wrote:
> > > > On Tue, Apr 18, 2006 at 09:01:10AM -0700, H. J. Lu wrote:
> > > > > Here is the updated patch. If section reserved for applications has
> > > > > SHF_ALLOC, linker can't handle it properly.
> > > > 
> > > > I'm curious.  Why doesn't the linker do what you expect?
> > > 
> > > It is not what I expect. It is I don't know what applications will
> > > expect.
> > 
> > Why is this any different for non-SHF_ALLOC sections?
> 
> non-SHF_ALLOC sections won't be the parts of image. We don't need to
> put them in segments.

Yes.

> We can leave them as is without changing the
> final image.

Well, maybe.  To be pedantic, they might need combining in special
ways.  However, I suppose just packing them together is the most
reasonable thing to do.

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.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: PATCH: ld/2537: Linker doesn't allow sections reserved for applications.
  2006-04-19  4:11           ` Alan Modra
@ 2006-04-19  4:16             ` H. J. Lu
  2006-04-19  5:59             ` Daniel Jacobowitz
  1 sibling, 0 replies; 23+ messages in thread
From: H. J. Lu @ 2006-04-19  4:16 UTC (permalink / raw)
  To: binutils

On Wed, Apr 19, 2006 at 12:05:25PM +0930, Alan Modra wrote:
> On Tue, Apr 18, 2006 at 07:01:46PM -0700, H. J. Lu wrote:
> > On Wed, Apr 19, 2006 at 10:03:39AM +0930, Alan Modra wrote:
> > > On Tue, Apr 18, 2006 at 05:13:19PM -0700, H. J. Lu wrote:
> > > > On Wed, Apr 19, 2006 at 09:20:16AM +0930, Alan Modra wrote:
> > > > > On Tue, Apr 18, 2006 at 09:01:10AM -0700, H. J. Lu wrote:
> > > > > > Here is the updated patch. If section reserved for applications has
> > > > > > SHF_ALLOC, linker can't handle it properly.
> > > > > 
> > > > > I'm curious.  Why doesn't the linker do what you expect?
> > > > 
> > > > It is not what I expect. It is I don't know what applications will
> > > > expect.
> > > 
> > > Why is this any different for non-SHF_ALLOC sections?
> > 
> > non-SHF_ALLOC sections won't be the parts of image. We don't need to
> > put them in segments.
> 
> Yes.
> 
> > We can leave them as is without changing the
> > final image.
> 
> Well, maybe.  To be pedantic, they might need combining in special
> ways.  However, I suppose just packing them together is the most
> reasonable thing to do.
> 
> 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.
> 

bed->elf_backend_section_from_shdr should handle SHT_LOPROC thru
SHT_HIPROC and SHT_LOOS thru SHT_HIOS since they are the part of psABI
or osABI. Otherwise, they won't be processed correctly.


H.J.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: PATCH: ld/2537: Linker doesn't allow sections reserved for applications.
  2006-04-19  4:11           ` Alan Modra
  2006-04-19  4:16             ` H. J. Lu
@ 2006-04-19  5:59             ` Daniel Jacobowitz
  2006-04-19  6:36               ` Daniel Jacobowitz
  2006-04-19 14:48               ` H. J. Lu
  1 sibling, 2 replies; 23+ messages in thread
From: Daniel Jacobowitz @ 2006-04-19  5:59 UTC (permalink / raw)
  To: binutils, binutils; +Cc: H. J. Lu

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 is one reason I've adapted to use readelf compulsively; I got sick
of "invalid format" errors from objdump.

-- 
Daniel Jacobowitz
CodeSourcery

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: PATCH: ld/2537: Linker doesn't allow sections reserved for applications.
  2006-04-19  5:59             ` Daniel Jacobowitz
@ 2006-04-19  6:36               ` Daniel Jacobowitz
  2006-04-19 14:48               ` H. J. Lu
  1 sibling, 0 replies; 23+ messages in thread
From: Daniel Jacobowitz @ 2006-04-19  6:36 UTC (permalink / raw)
  To: binutils, binutils; +Cc: H. J. Lu

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 is one reason I've adapted to use readelf compulsively; I got sick
of "invalid format" errors from objdump.

-- 
Daniel Jacobowitz
CodeSourcery

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: PATCH: ld/2537: Linker doesn't allow sections reserved for applications.
  2006-04-19  5:59             ` Daniel Jacobowitz
  2006-04-19  6:36               ` Daniel Jacobowitz
@ 2006-04-19 14:48               ` H. J. Lu
  2006-04-19 14:55                 ` H. J. Lu
  2006-04-19 16:59                 ` H. J. Lu
  1 sibling, 2 replies; 23+ messages in thread
From: H. J. Lu @ 2006-04-19 14:48 UTC (permalink / raw)
  To: binutils, binutils

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.


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 07:08:54.000000000 -0700
@@ -2159,8 +2159,34 @@ bfd_section_from_shdr (bfd *abfd, unsign
 
     default:
       /* Check for any processor-specific section types.  */
-      return bed->elf_backend_section_from_shdr (abfd, hdr, name,
-						 shindex);
+      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?  */
+	      (*_bfd_error_handler)
+	       (_("%B: don't know how to handle allocated, application"
+		  " specific section `%s' [0x%8x]"),
+		abfd, name, hdr->sh_type);
+	      return FALSE;
+	    }
+	  else
+	    /* Allow sections reserved for applications.  */
+	    return _bfd_elf_make_section_from_shdr (abfd, hdr, name,
+						    shindex);
+	}
+
+      /* FIXME: We should handle this section.  */
+      (*_bfd_error_handler)
+	(_("%B: don't know how to handle psABI/osABI specific"
+	   " section `%s' [0x%8x]"),
+	   abfd, name, hdr->sh_type);
+
+      return FALSE;
     }
 
   return TRUE;

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: PATCH: ld/2537: Linker doesn't allow sections reserved for applications.
  2006-04-19 14:48               ` H. J. Lu
@ 2006-04-19 14:55                 ` H. J. Lu
  2006-04-19 16:59                 ` H. J. Lu
  1 sibling, 0 replies; 23+ messages in thread
From: H. J. Lu @ 2006-04-19 14:55 UTC (permalink / raw)
  To: binutils, binutils

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.


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 07:08:54.000000000 -0700
@@ -2159,8 +2159,34 @@ bfd_section_from_shdr (bfd *abfd, unsign
 
     default:
       /* Check for any processor-specific section types.  */
-      return bed->elf_backend_section_from_shdr (abfd, hdr, name,
-						 shindex);
+      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?  */
+	      (*_bfd_error_handler)
+	       (_("%B: don't know how to handle allocated, application"
+		  " specific section `%s' [0x%8x]"),
+		abfd, name, hdr->sh_type);
+	      return FALSE;
+	    }
+	  else
+	    /* Allow sections reserved for applications.  */
+	    return _bfd_elf_make_section_from_shdr (abfd, hdr, name,
+						    shindex);
+	}
+
+      /* FIXME: We should handle this section.  */
+      (*_bfd_error_handler)
+	(_("%B: don't know how to handle psABI/osABI specific"
+	   " section `%s' [0x%8x]"),
+	   abfd, name, hdr->sh_type);
+
+      return FALSE;
     }
 
   return TRUE;

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: PATCH: ld/2537: Linker doesn't allow sections reserved for applications.
  2006-04-19 14:48               ` H. J. Lu
  2006-04-19 14:55                 ` H. J. Lu
@ 2006-04-19 16:59                 ` H. J. Lu
  2006-04-19 18:14                   ` H. J. Lu
                                     ` (2 more replies)
  1 sibling, 3 replies; 23+ messages in thread
From: H. J. Lu @ 2006-04-19 16:59 UTC (permalink / raw)
  To: binutils, binutils

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;

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: PATCH: ld/2537: Linker doesn't allow sections reserved for applications.
  2006-04-19 16:59                 ` H. J. Lu
@ 2006-04-19 18:14                   ` H. J. Lu
  2006-04-19 19:32                   ` Daniel Jacobowitz
  2006-04-19 20:44                   ` Andreas Schwab
  2 siblings, 0 replies; 23+ messages in thread
From: H. J. Lu @ 2006-04-19 18:14 UTC (permalink / raw)
  To: binutils, binutils

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;

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: PATCH: ld/2537: Linker doesn't allow sections reserved for applications.
  2006-04-19 16:59                 ` H. J. Lu
  2006-04-19 18:14                   ` H. J. Lu
@ 2006-04-19 19:32                   ` Daniel Jacobowitz
  2006-04-19 20:44                   ` Andreas Schwab
  2 siblings, 0 replies; 23+ messages in thread
From: Daniel Jacobowitz @ 2006-04-19 19:32 UTC (permalink / raw)
  To: binutils

On Wed, Apr 19, 2006 at 09:19:33AM -0700, H. J. Lu wrote:
> +	  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);

Please don't break i18n this way.  Use complete sentences, not %s
fragments.

-- 
Daniel Jacobowitz
CodeSourcery

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: PATCH: ld/2537: Linker doesn't allow sections reserved for applications.
  2006-04-19 16:59                 ` H. J. Lu
  2006-04-19 18:14                   ` H. J. Lu
  2006-04-19 19:32                   ` Daniel Jacobowitz
@ 2006-04-19 20:44                   ` Andreas Schwab
  2006-04-19 20:46                     ` Andreas Schwab
  2006-04-20  5:29                     ` H. J. Lu
  2 siblings, 2 replies; 23+ messages in thread
From: Andreas Schwab @ 2006-04-19 20:44 UTC (permalink / raw)
  To: H. J. Lu; +Cc: binutils, binutils

"H. J. Lu" <hjl@lucon.org> writes:

> +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);

This is not i18n-friendly.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: PATCH: ld/2537: Linker doesn't allow sections reserved for applications.
  2006-04-19 20:44                   ` Andreas Schwab
@ 2006-04-19 20:46                     ` Andreas Schwab
  2006-04-20  5:29                     ` H. J. Lu
  1 sibling, 0 replies; 23+ messages in thread
From: Andreas Schwab @ 2006-04-19 20:46 UTC (permalink / raw)
  To: H. J. Lu; +Cc: binutils, binutils

"H. J. Lu" <hjl@lucon.org> writes:

> +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);

This is not i18n-friendly.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: PATCH: ld/2537: Linker doesn't allow sections reserved for applications.
  2006-04-19 20:44                   ` Andreas Schwab
  2006-04-19 20:46                     ` Andreas Schwab
@ 2006-04-20  5:29                     ` H. J. Lu
  2006-04-20 16:35                       ` Maciej W. Rozycki
  1 sibling, 1 reply; 23+ messages in thread
From: H. J. Lu @ 2006-04-20  5:29 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: binutils

On Wed, Apr 19, 2006 at 06:38:39PM +0200, Andreas Schwab wrote:
> "H. J. Lu" <hjl@lucon.org> writes:
> 
> > +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);
> 
> This is not i18n-friendly.
> 
> Andreas.
> 

I updated it. Do you have other suggestions?



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 12:54:33.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;

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: PATCH: ld/2537: Linker doesn't allow sections reserved for  applications.
  2006-04-20  5:29                     ` H. J. Lu
@ 2006-04-20 16:35                       ` Maciej W. Rozycki
  2006-04-20 18:29                         ` H. J. Lu
  0 siblings, 1 reply; 23+ messages in thread
From: Maciej W. Rozycki @ 2006-04-20 16:35 UTC (permalink / raw)
  To: H. J. Lu; +Cc: Andreas Schwab, binutils

On Wed, 19 Apr 2006, H. J. Lu wrote:

> I updated it. Do you have other suggestions?
[...]
> +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);

 The order of phrases in a clause is language-specific -- why don't you 
simply use three distinct sentences?

  Maciej

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: PATCH: ld/2537: Linker doesn't allow sections reserved for  applications.
  2006-04-20 16:35                       ` Maciej W. Rozycki
@ 2006-04-20 18:29                         ` H. J. Lu
  2006-04-21  8:32                           ` Alan Modra
  0 siblings, 1 reply; 23+ messages in thread
From: H. J. Lu @ 2006-04-20 18:29 UTC (permalink / raw)
  To: Maciej W. Rozycki; +Cc: Andreas Schwab, binutils

On Thu, Apr 20, 2006 at 03:50:31PM +0100, Maciej W. Rozycki wrote:
> On Wed, 19 Apr 2006, H. J. Lu wrote:
> 
> > I updated it. Do you have other suggestions?
> [...]
> > +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);
> 
>  The order of phrases in a clause is language-specific -- why don't you 
> simply use three distinct sentences?
> 

Here is the new patch.


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-20 08:34:26.000000000 -0700
@@ -2159,8 +2159,43 @@ bfd_section_from_shdr (bfd *abfd, unsign
 
     default:
       /* Check for any processor-specific section types.  */
-      return bed->elf_backend_section_from_shdr (abfd, hdr, name,
-						 shindex);
+      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?  */
+	    (*_bfd_error_handler)
+	      (_("%B: don't know how to handle allocated, application "
+		 "specific section `%s' [0x%8x]"),
+	       abfd, name, hdr->sh_type);
+	  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)
+	/* FIXME: We should handle this section.  */
+	(*_bfd_error_handler)
+	  (_("%B: don't know how to handle processor specific section "
+	     "`%s' [0x%8x]"),
+	   abfd, name, hdr->sh_type);
+      else if (hdr->sh_type >= SHT_LOOS && hdr->sh_type <= SHT_HIOS)
+	/* FIXME: We should handle this section.  */
+	(*_bfd_error_handler)
+	  (_("%B: don't know how to handle OS specific section "
+	     "`%s' [0x%8x]"),
+	   abfd, name, hdr->sh_type);
+      else
+	/* FIXME: We should handle this section.  */
+	(*_bfd_error_handler)
+	  (_("%B: don't know how to handle section `%s' [0x%8x]"),
+	   abfd, name, hdr->sh_type);
+
+      return FALSE;
     }
 
   return TRUE;

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: PATCH: ld/2537: Linker doesn't allow sections reserved for  applications.
  2006-04-20 18:29                         ` H. J. Lu
@ 2006-04-21  8:32                           ` Alan Modra
  0 siblings, 0 replies; 23+ messages in thread
From: Alan Modra @ 2006-04-21  8:32 UTC (permalink / raw)
  To: H. J. Lu; +Cc: binutils

On Thu, Apr 20, 2006 at 08:36:47AM -0700, H. J. Lu wrote:
> 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.

OK.  There is a potential future problem here if we ever have two
targets that use the same ELF header but have different
elf_backend_section_from_shdr functions.  BFD might try the wrong target
vector first and issue an inappropriate error message.  Note that the
place where we could check OSABI, elf_backend_object_p, is called
*after* bfd_section_from_shdr is called for all the sections, in order
to tweak the bfd sections.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2006-04-21  3:23 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-15  0:08 PATCH: ld/2537: Linker doesn't allow sections reserved for applications H. J. Lu
2006-04-18 16:03 ` H. J. Lu
2006-04-18 17:26   ` Nick Clifton
2006-04-18 20:37     ` H. J. Lu
2006-04-19  0:13   ` Alan Modra
2006-04-19  0:33     ` H. J. Lu
2006-04-19  1:54       ` Alan Modra
2006-04-19  2:09         ` H. J. Lu
2006-04-19  4:11           ` Alan Modra
2006-04-19  4:16             ` H. J. Lu
2006-04-19  5:59             ` Daniel Jacobowitz
2006-04-19  6:36               ` Daniel Jacobowitz
2006-04-19 14:48               ` H. J. Lu
2006-04-19 14:55                 ` H. J. Lu
2006-04-19 16:59                 ` H. J. Lu
2006-04-19 18:14                   ` H. J. Lu
2006-04-19 19:32                   ` Daniel Jacobowitz
2006-04-19 20:44                   ` Andreas Schwab
2006-04-19 20:46                     ` Andreas Schwab
2006-04-20  5:29                     ` H. J. Lu
2006-04-20 16:35                       ` Maciej W. Rozycki
2006-04-20 18:29                         ` H. J. Lu
2006-04-21  8:32                           ` Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).