public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* "Warning: size of symbol FOO changed from X to Y in OBJ"
@ 2001-05-29 23:50 Philip Blundell
  2001-05-30  0:01 ` Geoff Keating
  2001-05-30 10:13 ` Ian Lance Taylor
  0 siblings, 2 replies; 16+ messages in thread
From: Philip Blundell @ 2001-05-29 23:50 UTC (permalink / raw)
  To: binutils

Despite the use of the word "warning", the linker seems to regard this as a 
fatal error.  I think a warning is probably more appropriate; anybody disagree?

p.


-- 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.5 (GNU/Linux)
Comment: Exmh version 2.1.1 10/15/1999 (debian)

iD8DBQE7FJg6VTLPJe9CT30RAhkCAJ9r4GUmJnkfj+kpU/c/ySvdNYjqmACfebqS
yNFRmctyaXvf/jF1b+12sxc=
=HneE
-----END PGP SIGNATURE-----

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

* Re: "Warning: size of symbol FOO changed from X to Y in OBJ"
  2001-05-29 23:50 "Warning: size of symbol FOO changed from X to Y in OBJ" Philip Blundell
@ 2001-05-30  0:01 ` Geoff Keating
  2001-05-30 10:13 ` Ian Lance Taylor
  1 sibling, 0 replies; 16+ messages in thread
From: Geoff Keating @ 2001-05-30  0:01 UTC (permalink / raw)
  To: philb; +Cc: binutils

> Date: Wed, 30 May 2001 07:50:34 +0100
> From: Philip Blundell <philb@gnu.org>

> Despite the use of the word "warning", the linker seems to regard
> this as a fatal error.  I think a warning is probably more
> appropriate; anybody disagree?

What application do you have where this is OK?

Usually it indicates a fatal problem.

-- 
- Geoffrey Keating <geoffk@geoffk.org>

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

* Re: "Warning: size of symbol FOO changed from X to Y in OBJ"
  2001-05-29 23:50 "Warning: size of symbol FOO changed from X to Y in OBJ" Philip Blundell
  2001-05-30  0:01 ` Geoff Keating
@ 2001-05-30 10:13 ` Ian Lance Taylor
  2001-05-30 16:56   ` amodra
  1 sibling, 1 reply; 16+ messages in thread
From: Ian Lance Taylor @ 2001-05-30 10:13 UTC (permalink / raw)
  To: Philip Blundell; +Cc: binutils

Philip Blundell <philb@gnu.org> writes:

> Despite the use of the word "warning", the linker seems to regard this as a 
> fatal error.  I think a warning is probably more appropriate; anybody disagree?

I certainly agree.  A symbol size change is not a fatal error.

Looking at the code, though, it doesn't seem to be a fatal error.  It
just seems to issue the warning and move on.  What's the test case?

Ian

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

* Re: "Warning: size of symbol FOO changed from X to Y in OBJ"
  2001-05-30 10:13 ` Ian Lance Taylor
@ 2001-05-30 16:56   ` amodra
  2001-05-30 19:26     ` Ian Lance Taylor
  0 siblings, 1 reply; 16+ messages in thread
From: amodra @ 2001-05-30 16:56 UTC (permalink / raw)
  To: binutils, philb

On Wed, May 30, 2001 at 10:12:48AM -0700, Ian Lance Taylor wrote:
> 
> Looking at the code, though, it doesn't seem to be a fatal error.  It
> just seems to issue the warning and move on.  What's the test case?

Aye, but ldlang.c:open_input_bfds has set the bfd error handler to
record_bfd_errors.  record_bfd_errors stops output file creation on
any error.

Alan

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

* Re: "Warning: size of symbol FOO changed from X to Y in OBJ"
  2001-05-30 16:56   ` amodra
@ 2001-05-30 19:26     ` Ian Lance Taylor
  2001-05-30 21:02       ` H . J . Lu
  0 siblings, 1 reply; 16+ messages in thread
From: Ian Lance Taylor @ 2001-05-30 19:26 UTC (permalink / raw)
  To: amodra, hjl; +Cc: binutils, philb

amodra@one.net.au writes:

> On Wed, May 30, 2001 at 10:12:48AM -0700, Ian Lance Taylor wrote:
> > 
> > Looking at the code, though, it doesn't seem to be a fatal error.  It
> > just seems to issue the warning and move on.  What's the test case?
> 
> Aye, but ldlang.c:open_input_bfds has set the bfd error handler to
> record_bfd_errors.  record_bfd_errors stops output file creation on
> any error.

Well, I don't know what that's about.  That's completely wrong.  If
BFD wants to report a fatal error, it should arrange to return false.
If BFD does not want to report a fatal error, it should not return
false.  It makes no sense for the linker to try to second guess BFD in
this regard.

According to the ChangeLog, H.J. added this:

2001-02-26  H.J. Lu  <hjl@gnu.org>

	* ldlang.c (open_input_bfds): Set the bfd error handler so
        that problems can be caught whilst loading symbols.
        (record_bfd_errors): New function: Report BFD errors and mark
        the executable output as being invalid.

Why?

Ian

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

* Re: "Warning: size of symbol FOO changed from X to Y in OBJ"
  2001-05-30 19:26     ` Ian Lance Taylor
@ 2001-05-30 21:02       ` H . J . Lu
  2001-05-30 23:55         ` Ian Lance Taylor
  0 siblings, 1 reply; 16+ messages in thread
From: H . J . Lu @ 2001-05-30 21:02 UTC (permalink / raw)
  To: binutils, philb, amodra; +Cc: nickc

On Wed, May 30, 2001 at 06:10:42PM -0700, Ian Lance Taylor wrote:
> amodra@one.net.au writes:
> 
> > On Wed, May 30, 2001 at 10:12:48AM -0700, Ian Lance Taylor wrote:
> > > 
> > > Looking at the code, though, it doesn't seem to be a fatal error.  It
> > > just seems to issue the warning and move on.  What's the test case?
> > 
> > Aye, but ldlang.c:open_input_bfds has set the bfd error handler to
> > record_bfd_errors.  record_bfd_errors stops output file creation on
> > any error.
> 
> Well, I don't know what that's about.  That's completely wrong.  If
> BFD wants to report a fatal error, it should arrange to return false.
> If BFD does not want to report a fatal error, it should not return
> false.  It makes no sense for the linker to try to second guess BFD in
> this regard.
> 
> According to the ChangeLog, H.J. added this:
> 
> 2001-02-26  H.J. Lu  <hjl@gnu.org>
> 
> 	* ldlang.c (open_input_bfds): Set the bfd error handler so
>         that problems can be caught whilst loading symbols.
>         (record_bfd_errors): New function: Report BFD errors and mark
>         the executable output as being invalid.
> 
> Why?

That patch was made after some discussions with Nick for

http://sources.redhat.com/ml/binutils/2001-02/msg00508.html

I guess for some platform, warning during symbol loading may be fatal.


H.J.

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

* Re: "Warning: size of symbol FOO changed from X to Y in OBJ"
  2001-05-30 21:02       ` H . J . Lu
@ 2001-05-30 23:55         ` Ian Lance Taylor
  2001-05-31  0:14           ` H . J . Lu
  2001-06-12 10:48           ` Nick Clifton
  0 siblings, 2 replies; 16+ messages in thread
From: Ian Lance Taylor @ 2001-05-30 23:55 UTC (permalink / raw)
  To: H . J . Lu; +Cc: binutils, philb, amodra, nickc

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

> > Well, I don't know what that's about.  That's completely wrong.  If
> > BFD wants to report a fatal error, it should arrange to return false.
> > If BFD does not want to report a fatal error, it should not return
> > false.  It makes no sense for the linker to try to second guess BFD in
> > this regard.
> > 
> > According to the ChangeLog, H.J. added this:
> > 
> > 2001-02-26  H.J. Lu  <hjl@gnu.org>
> > 
> > 	* ldlang.c (open_input_bfds): Set the bfd error handler so
> >         that problems can be caught whilst loading symbols.
> >         (record_bfd_errors): New function: Report BFD errors and mark
> >         the executable output as being invalid.
> > 
> > Why?
> 
> That patch was made after some discussions with Nick for
> 
> http://sources.redhat.com/ml/binutils/2001-02/msg00508.html
> 
> I guess for some platform, warning during symbol loading may be fatal.

Yes, that is definitely true.  However, if BFD wants to report a fatal
error, it should arrange to return false.  Calling _bfd_error_handler
is not a mechanism for reporting a fatal error.

It's true that styp_to_sec_flags currently has no way to report error.
However, that is easily fixed.  Once that is done, it's easy to change
make_a_section_from_file to check for an error return and return false
if it finds one.

Having the linker look look for warning messages and treat them as
fatal makes no sense.  It's not even simpler than doing the right
thing.  It's the kind of thing you would do if you couldn't change the
source code.

Ian

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

* Re: "Warning: size of symbol FOO changed from X to Y in OBJ"
  2001-05-30 23:55         ` Ian Lance Taylor
@ 2001-05-31  0:14           ` H . J . Lu
  2001-05-31  0:26             ` Ian Lance Taylor
  2001-05-31  1:49             ` Nick Clifton
  2001-06-12 10:48           ` Nick Clifton
  1 sibling, 2 replies; 16+ messages in thread
From: H . J . Lu @ 2001-05-31  0:14 UTC (permalink / raw)
  To: binutils, philb, amodra, nickc

On Wed, May 30, 2001 at 11:54:29PM -0700, Ian Lance Taylor wrote:
> 
> Yes, that is definitely true.  However, if BFD wants to report a fatal
> error, it should arrange to return false.  Calling _bfd_error_handler
> is not a mechanism for reporting a fatal error.
> 
> It's true that styp_to_sec_flags currently has no way to report error.
> However, that is easily fixed.  Once that is done, it's easy to change
> make_a_section_from_file to check for an error return and return false
> if it finds one.

I have no objections to revert my patch. I will leave it to Nick.

BTW, I believe "Warning: size of symbol FOO changed from X to Y in OBJ"
is a fatal error if X > Y.


H.J.

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

* Re: "Warning: size of symbol FOO changed from X to Y in OBJ"
  2001-05-31  0:14           ` H . J . Lu
@ 2001-05-31  0:26             ` Ian Lance Taylor
  2001-05-31  9:35               ` H . J . Lu
  2001-05-31  1:49             ` Nick Clifton
  1 sibling, 1 reply; 16+ messages in thread
From: Ian Lance Taylor @ 2001-05-31  0:26 UTC (permalink / raw)
  To: H . J . Lu; +Cc: binutils, philb, amodra, nickc

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

> BTW, I believe "Warning: size of symbol FOO changed from X to Y in OBJ"
> is a fatal error if X > Y.

That is not clear to me.  For cases where this warning arises, the
linker is not going to take any action based on the symbol size.  The
linker only uses the symbol size for common symbols, and changes in
common symbol size are handled in a different way.

Ian

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

* Re: "Warning: size of symbol FOO changed from X to Y in OBJ"
  2001-05-31  0:14           ` H . J . Lu
  2001-05-31  0:26             ` Ian Lance Taylor
@ 2001-05-31  1:49             ` Nick Clifton
  2001-05-31 11:57               ` H . J . Lu
  1 sibling, 1 reply; 16+ messages in thread
From: Nick Clifton @ 2001-05-31  1:49 UTC (permalink / raw)
  To: H . J . Lu; +Cc: binutils, philb, amodra

Hi H.J.

> I have no objections to revert my patch. I will leave it to Nick.
> 
> BTW, I believe "Warning: size of symbol FOO changed from X to Y in OBJ"
> is a fatal error if X > Y.

OK, let's do the right thing.  H.J.  If you would please revert your
patch, and then, if you wish, fix styp_to_sec_flags and
make_a_section_from_file to repoprt and handle errors.  If not, then I
will try to do so myself sometime during the next week.

Cheers
        Nick



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

* Re: "Warning: size of symbol FOO changed from X to Y in OBJ"
  2001-05-31  0:26             ` Ian Lance Taylor
@ 2001-05-31  9:35               ` H . J . Lu
  2001-05-31 10:33                 ` Ian Lance Taylor
  0 siblings, 1 reply; 16+ messages in thread
From: H . J . Lu @ 2001-05-31  9:35 UTC (permalink / raw)
  To: binutils, philb, amodra, nickc

On Thu, May 31, 2001 at 12:25:21AM -0700, Ian Lance Taylor wrote:
> "H . J . Lu" <hjl@lucon.org> writes:
> 
> > BTW, I believe "Warning: size of symbol FOO changed from X to Y in OBJ"
> > is a fatal error if X > Y.
> 
> That is not clear to me.  For cases where this warning arises, the
> linker is not going to take any action based on the symbol size.  The
> linker only uses the symbol size for common symbols, and changes in
> common symbol size are handled in a different way.

I thought the warning was for common symbol. In any case, if you
override a definition with another one of a smaller size, I believe
something will go wrong if some code still uses the larger size.

I'd like to see a testcase for it.


H.J.

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

* Re: "Warning: size of symbol FOO changed from X to Y in OBJ"
  2001-05-31  9:35               ` H . J . Lu
@ 2001-05-31 10:33                 ` Ian Lance Taylor
  2001-05-31 11:23                   ` H . J . Lu
  0 siblings, 1 reply; 16+ messages in thread
From: Ian Lance Taylor @ 2001-05-31 10:33 UTC (permalink / raw)
  To: H . J . Lu; +Cc: binutils, philb, amodra, nickc

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

> On Thu, May 31, 2001 at 12:25:21AM -0700, Ian Lance Taylor wrote:
> > "H . J . Lu" <hjl@lucon.org> writes:
> > 
> > > BTW, I believe "Warning: size of symbol FOO changed from X to Y in OBJ"
> > > is a fatal error if X > Y.
> > 
> > That is not clear to me.  For cases where this warning arises, the
> > linker is not going to take any action based on the symbol size.  The
> > linker only uses the symbol size for common symbols, and changes in
> > common symbol size are handled in a different way.
> 
> I thought the warning was for common symbol. In any case, if you
> override a definition with another one of a smaller size, I believe
> something will go wrong if some code still uses the larger size.

That warning is not for common symbols.  Merging of common symbols is
handled in elf_merge_symbol, and that sets size_change_ok, which
prevents the above warning.

The symbol size only has an actual effect for common symbols and for
symbols which are the subject of a COPY relocation.  In other cases,
as in the size of a function, the symbol size is only a comment.
Since nothing uses the size, it doesn't matter which size appears in
the executable.

I suppose it's conceivable that setting the symbol size to the smaller
size could cause a bug.  But I can't think of any case in which that
would happen.  So I would want more than speculation.

Ian

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

* Re: "Warning: size of symbol FOO changed from X to Y in OBJ"
  2001-05-31 10:33                 ` Ian Lance Taylor
@ 2001-05-31 11:23                   ` H . J . Lu
  0 siblings, 0 replies; 16+ messages in thread
From: H . J . Lu @ 2001-05-31 11:23 UTC (permalink / raw)
  To: binutils, philb, amodra, nickc

On Thu, May 31, 2001 at 10:31:47AM -0700, Ian Lance Taylor wrote:
> 
> I suppose it's conceivable that setting the symbol size to the smaller
> size could cause a bug.  But I can't think of any case in which that
> would happen.  So I would want more than speculation.
> 

Me too. I'd like to see a testcase for such a warning.


H.J.

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

* Re: "Warning: size of symbol FOO changed from X to Y in OBJ"
  2001-05-31  1:49             ` Nick Clifton
@ 2001-05-31 11:57               ` H . J . Lu
  2001-05-31 12:08                 ` Ian Lance Taylor
  0 siblings, 1 reply; 16+ messages in thread
From: H . J . Lu @ 2001-05-31 11:57 UTC (permalink / raw)
  To: Nick Clifton; +Cc: binutils, philb, amodra

On Thu, May 31, 2001 at 10:46:38AM +0100, Nick Clifton wrote:
> Hi H.J.
> 
> > I have no objections to revert my patch. I will leave it to Nick.
> > 
> > BTW, I believe "Warning: size of symbol FOO changed from X to Y in OBJ"
> > is a fatal error if X > Y.
> 
> OK, let's do the right thing.  H.J.  If you would please revert your
> patch, and then, if you wish, fix styp_to_sec_flags and
> make_a_section_from_file to repoprt and handle errors.  If not, then I
> will try to do so myself sometime during the next week.

I'd like to see a testcase for the problem before we do anything.



H.J.

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

* Re: "Warning: size of symbol FOO changed from X to Y in OBJ"
  2001-05-31 11:57               ` H . J . Lu
@ 2001-05-31 12:08                 ` Ian Lance Taylor
  0 siblings, 0 replies; 16+ messages in thread
From: Ian Lance Taylor @ 2001-05-31 12:08 UTC (permalink / raw)
  To: H . J . Lu; +Cc: Nick Clifton, binutils, philb, amodra

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

> On Thu, May 31, 2001 at 10:46:38AM +0100, Nick Clifton wrote:
> > Hi H.J.
> > 
> > > I have no objections to revert my patch. I will leave it to Nick.
> > > 
> > > BTW, I believe "Warning: size of symbol FOO changed from X to Y in OBJ"
> > > is a fatal error if X > Y.
> > 
> > OK, let's do the right thing.  H.J.  If you would please revert your
> > patch, and then, if you wish, fix styp_to_sec_flags and
> > make_a_section_from_file to repoprt and handle errors.  If not, then I
> > will try to do so myself sometime during the next week.
> 
> I'd like to see a testcase for the problem before we do anything.

The current code is obviously wrong.  That has nothing to do with any
issues related to the size of symbol.

If the symbol size should be treated as a fatal error, then
elf_link_add_object_symbols should return false in that case.

The linker should not second guess BFD.  That makes no sense at all.

Ian

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

* Re: "Warning: size of symbol FOO changed from X to Y in OBJ"
  2001-05-30 23:55         ` Ian Lance Taylor
  2001-05-31  0:14           ` H . J . Lu
@ 2001-06-12 10:48           ` Nick Clifton
  1 sibling, 0 replies; 16+ messages in thread
From: Nick Clifton @ 2001-06-12 10:48 UTC (permalink / raw)
  To: ian, hjl; +Cc: binutils

Hi Ian,  Hi H.J.

  OK I have two patches for this.  The first one changes
  load_symbols() in the linker so that it becomes a boolean function
  and can return a failure from the bfd routines back to its parent.

  The second patch changes styp_to_sec_flags() to return a boolean,
  and changes make_a_section_from_file() to examine this return value.

  Rather than just apply them though, I am posting them first in case
  anybody wants to review or comment on them.  If I do not hear
  anything then I will just check them in.

Cheers
        Nick

ld/ChangeLog
2001-06-12  Nick Clifton  <nickc@cambridge.redhat.com>

	* ldlang.c (walk_wild): Only call walk_wild_file if
	lookup_name returns something.
        (lookup_name): If load_symbols fails, return NULL.
        (load_symbols): Chnage to a boolean function.
        (open_input_bfds): If load_symbols fails then do not make the
	executable.

bfd/ChangeLog
2001-06-12  Nick Clifton  <nickc@cambridge.redhat.com>

	* coffcode.h (styp_flags_to_sec_flags): Change to a boolean
	function.  Move flagword result into parameter list.  Remove
	comment about setting bfd_error_handler to intercept failure
	results.
        * coffgen.c (make_a_section_from_file): Examine result of
	calling bfd_coff_styp_to_sec_flags and pass a failure back to
	caller.
        * ecoff.h (styp_flags_to_sec_flags): Change to a boolean
	function.  Move flagword result into parameter list.
        * libcoff.h: Regenerate.
        * libecoff.h: Regenerate.

Index: ld/ldlang.c
===================================================================
RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.49
diff -p -r1.49 ldlang.c
*** ldlang.c	2001/06/08 01:58:20	1.49
--- ldlang.c	2001/06/12 17:25:03
*************** static void output_section_callback
*** 84,90 ****
    PARAMS ((lang_wild_statement_type *, asection *,
  	   lang_input_statement_type *, PTR));
  static lang_input_statement_type *lookup_name PARAMS ((const char *));
! static void load_symbols
    PARAMS ((lang_input_statement_type *, lang_statement_list_type *));
  static void wild
    PARAMS ((lang_wild_statement_type *, const char *, const char *,
--- 84,90 ----
    PARAMS ((lang_wild_statement_type *, asection *,
  	   lang_input_statement_type *, PTR));
  static lang_input_statement_type *lookup_name PARAMS ((const char *));
! static boolean load_symbols
    PARAMS ((lang_input_statement_type *, lang_statement_list_type *));
  static void wild
    PARAMS ((lang_wild_statement_type *, const char *, const char *,
*************** walk_wild (s, section, file, callback, d
*** 360,366 ****
  
        /* Perform the iteration over a single file.  */
        f = lookup_name (file);
!       walk_wild_file (s, section, f, callback, data);
      }
  }
  
--- 360,367 ----
  
        /* Perform the iteration over a single file.  */
        f = lookup_name (file);
!       if (f)
! 	walk_wild_file (s, section, f, callback, data);
      }
  }
  
*************** lookup_name (name)
*** 1425,1438 ****
        || search->filename == (const char *) NULL)
      return search;
  
!   load_symbols (search, (lang_statement_list_type *) NULL);
  
    return search;
  }
  
  /* Get the symbols for an input file.  */
  
! static void
  load_symbols (entry, place)
       lang_input_statement_type *entry;
       lang_statement_list_type *place;
--- 1426,1440 ----
        || search->filename == (const char *) NULL)
      return search;
  
!   if (! load_symbols (search, (lang_statement_list_type *) NULL))
!     return NULL;
  
    return search;
  }
  
  /* Get the symbols for an input file.  */
  
! static boolean
  load_symbols (entry, place)
       lang_input_statement_type *entry;
       lang_statement_list_type *place;
*************** load_symbols (entry, place)
*** 1440,1446 ****
    char **matching;
  
    if (entry->loaded)
!     return;
  
    ldfile_open_file (entry);
  
--- 1442,1448 ----
    char **matching;
  
    if (entry->loaded)
!     return true;
  
    ldfile_open_file (entry);
  
*************** load_symbols (entry, place)
*** 1449,1460 ****
      {
        bfd_error_type err;
        lang_statement_list_type *hold;
! 
        err = bfd_get_error ();
  
        /* See if the emulation has some special knowledge.  */
        if (ldemul_unrecognized_file (entry))
! 	return;
  
        if (err == bfd_error_file_ambiguously_recognized)
  	{
--- 1451,1463 ----
      {
        bfd_error_type err;
        lang_statement_list_type *hold;
!       boolean bad_load = true;
!       
        err = bfd_get_error ();
  
        /* See if the emulation has some special knowledge.  */
        if (ldemul_unrecognized_file (entry))
! 	return true;
  
        if (err == bfd_error_file_ambiguously_recognized)
  	{
*************** load_symbols (entry, place)
*** 1468,1475 ****
  	}
        else if (err != bfd_error_file_not_recognized
  	       || place == NULL)
! 	einfo (_("%F%B: file not recognized: %E\n"), entry->the_bfd);
! 
        bfd_close (entry->the_bfd);
        entry->the_bfd = NULL;
  
--- 1471,1480 ----
  	}
        else if (err != bfd_error_file_not_recognized
  	       || place == NULL)
! 	  einfo (_("%F%B: file not recognized: %E\n"), entry->the_bfd);
!       else
! 	bad_load = false;
!       
        bfd_close (entry->the_bfd);
        entry->the_bfd = NULL;
  
*************** load_symbols (entry, place)
*** 1486,1496 ****
  
        stat_ptr = hold;
  
!       return;
      }
  
    if (ldemul_recognized_file (entry))
!     return;
  
    /* We don't call ldlang_add_file for an archive.  Instead, the
       add_symbols entry point will call ldlang_add_file, via the
--- 1491,1501 ----
  
        stat_ptr = hold;
  
!       return ! bad_load;
      }
  
    if (ldemul_recognized_file (entry))
!     return true;
  
    /* We don't call ldlang_add_file for an archive.  Instead, the
       add_symbols entry point will call ldlang_add_file, via the
*************** load_symbols (entry, place)
*** 1510,1541 ****
      case bfd_archive:
        if (entry->whole_archive)
  	{
! 	  bfd *member = bfd_openr_next_archived_file (entry->the_bfd,
! 						      (bfd *) NULL);
! 	  while (member != NULL)
  	    {
  	      if (! bfd_check_format (member, bfd_object))
! 		einfo (_("%F%B: object %B in archive is not object\n"),
! 		       entry->the_bfd, member);
  	      if (! ((*link_info.callbacks->add_archive_element)
  		     (&link_info, member, "--whole-archive")))
  		abort ();
  	      if (! bfd_link_add_symbols (member, &link_info))
! 		einfo (_("%F%B: could not read symbols: %E\n"), member);
! 	      member = bfd_openr_next_archived_file (entry->the_bfd,
! 						     member);
  	    }
- 
- 	  entry->loaded = true;
  
! 	  return;
  	}
      }
  
!   if (! bfd_link_add_symbols (entry->the_bfd, &link_info))
      einfo (_("%F%B: could not read symbols: %E\n"), entry->the_bfd);
  
!   entry->loaded = true;
  }
  
  /* Handle a wild statement.  SECTION or FILE or both may be NULL,
--- 1515,1560 ----
      case bfd_archive:
        if (entry->whole_archive)
  	{
! 	  bfd * member = NULL;
! 	  boolean loaded = true;
! 
! 	  for (;;)
  	    {
+ 	      member = bfd_openr_next_archived_file (entry->the_bfd, member);
+ 
+ 	      if (member == NULL)
+ 		break;
+ 	      
  	      if (! bfd_check_format (member, bfd_object))
! 		{
! 		  einfo (_("%F%B: member %B in archive is not an object\n"),
! 			 entry->the_bfd, member);
! 		  loaded = false;
! 		}
! 
  	      if (! ((*link_info.callbacks->add_archive_element)
  		     (&link_info, member, "--whole-archive")))
  		abort ();
+ 
  	      if (! bfd_link_add_symbols (member, &link_info))
! 		{
! 		  einfo (_("%F%B: could not read symbols: %E\n"), member);
! 		  loaded = false;
! 		}
  	    }
  
! 	  entry->loaded = loaded;
! 	  return loaded;
  	}
+       break;
      }
  
!   if (bfd_link_add_symbols (entry->the_bfd, &link_info))
!     entry->loaded = true;
!   else
      einfo (_("%F%B: could not read symbols: %E\n"), entry->the_bfd);
  
!   return entry->loaded;
  }
  
  /* Handle a wild statement.  SECTION or FILE or both may be NULL,
*************** open_input_bfds (s, force)
*** 1929,1935 ****
  
  	      lang_list_init (&add);
  
! 	      load_symbols (&s->input_statement, &add);
  
  	      if (add.head != NULL)
  		{
--- 1948,1955 ----
  
  	      lang_list_init (&add);
  
! 	      if (! load_symbols (&s->input_statement, &add))
! 		config.make_executable = false;
  
  	      if (add.head != NULL)
  		{

Index: bfd/coffcode.h
===================================================================
RCS file: /cvs/src/src/bfd/coffcode.h,v
retrieving revision 1.58
diff -p -r1.58 coffcode.h
*** coffcode.h	2001/05/24 20:50:50	1.58
--- coffcode.h	2001/06/12 17:26:00
*************** CODE_FRAGMENT
*** 312,319 ****
  #define STRING_SIZE_SIZE (4)
  
  static long sec_to_styp_flags PARAMS ((const char *, flagword));
! static flagword styp_to_sec_flags
!   PARAMS ((bfd *, PTR, const char *, asection *));
  static boolean coff_bad_format_hook PARAMS ((bfd *, PTR));
  static void coff_set_custom_section_alignment
    PARAMS ((bfd *, asection *, const struct coff_section_alignment_entry *,
--- 312,319 ----
  #define STRING_SIZE_SIZE (4)
  
  static long sec_to_styp_flags PARAMS ((const char *, flagword));
! static boolean styp_to_sec_flags
!   PARAMS ((bfd *, PTR, const char *, asection *, flagword *));
  static boolean coff_bad_format_hook PARAMS ((bfd *, PTR));
  static void coff_set_custom_section_alignment
    PARAMS ((bfd *, asection *, const struct coff_section_alignment_entry *,
*************** sec_to_styp_flags (sec_name, sec_flags)
*** 553,564 ****
  
  #ifndef COFF_WITH_PE
  
! static flagword
! styp_to_sec_flags (abfd, hdr, name, section)
       bfd *abfd ATTRIBUTE_UNUSED;
       PTR hdr;
       const char *name;
       asection *section ATTRIBUTE_UNUSED;
  {
    struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
    long styp_flags = internal_s->s_flags;
--- 553,565 ----
  
  #ifndef COFF_WITH_PE
  
! static boolean
! styp_to_sec_flags (abfd, hdr, name, section, flags_ptr)
       bfd *abfd ATTRIBUTE_UNUSED;
       PTR hdr;
       const char *name;
       asection *section ATTRIBUTE_UNUSED;
+      flagword *flags_ptr;
  {
    struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
    long styp_flags = internal_s->s_flags;
*************** styp_to_sec_flags (abfd, hdr, name, sect
*** 566,584 ****
  
  #ifdef STYP_BLOCK
    if (styp_flags & STYP_BLOCK)
!       sec_flags |= SEC_BLOCK;
  #endif
  
  #ifdef STYP_CLINK
    if (styp_flags & STYP_CLINK)
!       sec_flags |= SEC_CLINK;
  #endif
  
  #ifdef STYP_NOLOAD
    if (styp_flags & STYP_NOLOAD)
!     {
!       sec_flags |= SEC_NEVER_LOAD;
!     }
  #endif /* STYP_NOLOAD */
  
    /* For 386 COFF, at least, an unloadable text or data section is
--- 567,583 ----
  
  #ifdef STYP_BLOCK
    if (styp_flags & STYP_BLOCK)
!     sec_flags |= SEC_BLOCK;
  #endif
  
  #ifdef STYP_CLINK
    if (styp_flags & STYP_CLINK)
!     sec_flags |= SEC_CLINK;
  #endif
  
  #ifdef STYP_NOLOAD
    if (styp_flags & STYP_NOLOAD)
!     sec_flags |= SEC_NEVER_LOAD;
  #endif /* STYP_NOLOAD */
  
    /* For 386 COFF, at least, an unloadable text or data section is
*************** styp_to_sec_flags (abfd, hdr, name, sect
*** 619,627 ****
  #endif
      }
    else if (styp_flags & STYP_PAD)
!     {
!       sec_flags = 0;
!     }
    else if (strcmp (name, _TEXT) == 0)
      {
        if (sec_flags & SEC_NEVER_LOAD)
--- 618,624 ----
  #endif
      }
    else if (styp_flags & STYP_PAD)
!     sec_flags = 0;
    else if (strcmp (name, _TEXT) == 0)
      {
        if (sec_flags & SEC_NEVER_LOAD)
*************** styp_to_sec_flags (abfd, hdr, name, sect
*** 664,689 ****
  #endif
  #ifdef _LIT
    else if (strcmp (name, _LIT) == 0)
!     {
!       sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY;
!     }
  #endif
    else
!     {
!       sec_flags |= SEC_ALLOC | SEC_LOAD;
!     }
  
  #ifdef STYP_LIT			/* A29k readonly text/data section type */
    if ((styp_flags & STYP_LIT) == STYP_LIT)
!     {
!       sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY);
!     }
  #endif /* STYP_LIT */
  #ifdef STYP_OTHER_LOAD		/* Other loaded sections */
    if (styp_flags & STYP_OTHER_LOAD)
!     {
!       sec_flags = (SEC_LOAD | SEC_ALLOC);
!     }
  #endif /* STYP_SDATA */
  
  #if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE)
--- 661,679 ----
  #endif
  #ifdef _LIT
    else if (strcmp (name, _LIT) == 0)
!     sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY;
  #endif
    else
!     sec_flags |= SEC_ALLOC | SEC_LOAD;
  
  #ifdef STYP_LIT			/* A29k readonly text/data section type */
    if ((styp_flags & STYP_LIT) == STYP_LIT)
!     sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY);
  #endif /* STYP_LIT */
+ 
  #ifdef STYP_OTHER_LOAD		/* Other loaded sections */
    if (styp_flags & STYP_OTHER_LOAD)
!     sec_flags = (SEC_LOAD | SEC_ALLOC);
  #endif /* STYP_SDATA */
  
  #if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE)
*************** styp_to_sec_flags (abfd, hdr, name, sect
*** 697,703 ****
      sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
  #endif
  
!   return sec_flags;
  }
  
  #else /* COFF_WITH_PE */
--- 687,697 ----
      sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
  #endif
  
!   if (flags_ptr == NULL)
!     return false;
! 
!   * flags_ptr = sec_flags;
!   return true;
  }
  
  #else /* COFF_WITH_PE */
*************** handle_COMDAT (abfd, sec_flags, hdr, nam
*** 966,981 ****
     required information.  FIXME: Is the COMDAT symbol index used for
     any purpose other than objdump?  */
  
! static flagword
! styp_to_sec_flags (abfd, hdr, name, section)
       bfd *abfd;
       PTR hdr;
       const char *name;
       asection *section;
  {
    struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
    long styp_flags = internal_s->s_flags;
    flagword sec_flags;
  
    /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
    sec_flags = SEC_READONLY;
--- 960,977 ----
     required information.  FIXME: Is the COMDAT symbol index used for
     any purpose other than objdump?  */
  
! static boolean
! styp_to_sec_flags (abfd, hdr, name, section, flags_ptr)
       bfd *abfd;
       PTR hdr;
       const char *name;
       asection *section;
+      flagword *flags_ptr;
  {
    struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
    long styp_flags = internal_s->s_flags;
    flagword sec_flags;
+   boolean result = true;
  
    /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
    sec_flags = SEC_READONLY;
*************** styp_to_sec_flags (abfd, hdr, name, sect
*** 1070,1083 ****
  	  break;	  
  	}
  
!       /* If the section flag was not handled, report it here.  This will allow
! 	 users of the BFD library to report a problem but continue executing.
! 	 Tools which need to be aware of these problems (such as the linker)
! 	 can override the default bfd_error_handler to intercept these reports.  */
        if (unhandled != NULL)
! 	(*_bfd_error_handler)
! 	  (_("%s (%s): Section flag %s (0x%x) ignored"),
! 	   bfd_get_filename (abfd), name, unhandled, flag);
      }
  
  #if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE)
--- 1066,1079 ----
  	  break;	  
  	}
  
!       /* If the section flag was not handled, report it here.  */
        if (unhandled != NULL)
! 	{
! 	  (*_bfd_error_handler)
! 	    (_("%s (%s): Section flag %s (0x%x) ignored"),
! 	     bfd_get_filename (abfd), name, unhandled, flag);
! 	  result = false;
! 	}
      }
  
  #if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE)
*************** styp_to_sec_flags (abfd, hdr, name, sect
*** 1091,1097 ****
      sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
  #endif
  
!   return sec_flags;
  }
  
  #endif /* COFF_WITH_PE */
--- 1087,1096 ----
      sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
  #endif
  
!   if (flags_ptr)
!     * flags_ptr = sec_flags;
!   
!   return result;
  }
  
  #endif /* COFF_WITH_PE */
*************** dependent COFF routines:
*** 1227,1237 ****
  .       bfd     *abfd,
  .       PTR     internal_filehdr,
  .       PTR     internal_aouthdr));
! . flagword (*_bfd_styp_to_sec_flags_hook) PARAMS ((
  .       bfd     *abfd,
  .       PTR     internal_scnhdr,
  .       const char *name,
! .       asection *section));
  . void (*_bfd_set_alignment_hook) PARAMS ((
  .       bfd     *abfd,
  .       asection *sec,
--- 1226,1237 ----
  .       bfd     *abfd,
  .       PTR     internal_filehdr,
  .       PTR     internal_aouthdr));
! . boolean (*_bfd_styp_to_sec_flags_hook) PARAMS ((
  .       bfd     *abfd,
  .       PTR     internal_scnhdr,
  .       const char *name,
! .       asection *section
! .       flagword *flags_ptr));
  . void (*_bfd_set_alignment_hook) PARAMS ((
  .       bfd     *abfd,
  .       asection *sec,
*************** dependent COFF routines:
*** 1385,1393 ****
  .#define bfd_coff_mkobject_hook(abfd, filehdr, aouthdr)\
  .        ((coff_backend_info (abfd)->_bfd_coff_mkobject_hook) (abfd, filehdr, aouthdr))
  .
! .#define bfd_coff_styp_to_sec_flags_hook(abfd, scnhdr, name, section)\
  .        ((coff_backend_info (abfd)->_bfd_styp_to_sec_flags_hook)\
! .         (abfd, scnhdr, name, section))
  .
  .#define bfd_coff_set_alignment_hook(abfd, sec, scnhdr)\
  .        ((coff_backend_info (abfd)->_bfd_set_alignment_hook) (abfd, sec, scnhdr))
--- 1385,1393 ----
  .#define bfd_coff_mkobject_hook(abfd, filehdr, aouthdr)\
  .        ((coff_backend_info (abfd)->_bfd_coff_mkobject_hook) (abfd, filehdr, aouthdr))
  .
! .#define bfd_coff_styp_to_sec_flags_hook(abfd, scnhdr, name, section, flags_ptr)\
  .        ((coff_backend_info (abfd)->_bfd_styp_to_sec_flags_hook)\
! .         (abfd, scnhdr, name, section, flags_ptr))
  .
  .#define bfd_coff_set_alignment_hook(abfd, sec, scnhdr)\
  .        ((coff_backend_info (abfd)->_bfd_set_alignment_hook) (abfd, sec, scnhdr))
Index: bfd/coffgen.c
===================================================================
RCS file: /cvs/src/src/bfd/coffgen.c,v
retrieving revision 1.21
diff -p -r1.21 coffgen.c
*** coffgen.c	2001/05/24 20:50:50	1.21
--- coffgen.c	2001/06/12 17:26:00
*************** make_a_section_from_file (abfd, hdr, tar
*** 82,87 ****
--- 82,89 ----
  {
    asection *return_section;
    char *name;
+   boolean result = true;
+   flagword flags;
  
    name = NULL;
  
*************** make_a_section_from_file (abfd, hdr, tar
*** 142,150 ****
    return_section->userdata = NULL;
    return_section->next = (asection *) NULL;
    return_section->target_index = target_index;
-   return_section->flags = bfd_coff_styp_to_sec_flags_hook (abfd, hdr, name,
- 							   return_section);
  
    /* At least on i386-coff, the line number count for a shared library
       section must be ignored.  */
    if ((return_section->flags & SEC_COFF_SHARED_LIBRARY) != 0)
--- 144,156 ----
    return_section->userdata = NULL;
    return_section->next = (asection *) NULL;
    return_section->target_index = target_index;
  
+   if (! bfd_coff_styp_to_sec_flags_hook (abfd, hdr, name, return_section,
+ 					 & flags))
+     result = false;
+   
+   return_section->flags = flags;
+ 
    /* At least on i386-coff, the line number count for a shared library
       section must be ignored.  */
    if ((return_section->flags & SEC_COFF_SHARED_LIBRARY) != 0)
*************** make_a_section_from_file (abfd, hdr, tar
*** 155,161 ****
    /* FIXME: should this check 'hdr->s_size > 0' */
    if (hdr->s_scnptr != 0)
      return_section->flags |= SEC_HAS_CONTENTS;
!   return true;
  }
  
  /* Read in a COFF object and make it into a BFD.  This is used by
--- 161,168 ----
    /* FIXME: should this check 'hdr->s_size > 0' */
    if (hdr->s_scnptr != 0)
      return_section->flags |= SEC_HAS_CONTENTS;
! 
!   return result;
  }
  
  /* Read in a COFF object and make it into a BFD.  This is used by
Index: bfd/ecoff.c
===================================================================
RCS file: /cvs/src/src/bfd/ecoff.c,v
retrieving revision 1.9
diff -p -r1.9 ecoff.c
*** ecoff.c	2001/05/17 03:58:45	1.9
--- ecoff.c	2001/06/12 17:26:05
*************** ecoff_sec_to_styp_flags (name, flags)
*** 371,386 ****
  
  /* Get the BFD flags to use for a section.  */
  
! flagword
! _bfd_ecoff_styp_to_sec_flags (abfd, hdr, name, section)
       bfd *abfd ATTRIBUTE_UNUSED;
       PTR hdr;
       const char *name ATTRIBUTE_UNUSED;
       asection *section ATTRIBUTE_UNUSED;
  {
    struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
    long styp_flags = internal_s->s_flags;
!   flagword sec_flags=0;
  
    if (styp_flags & STYP_NOLOAD)
      sec_flags |= SEC_NEVER_LOAD;
--- 371,387 ----
  
  /* Get the BFD flags to use for a section.  */
  
! boolean
! _bfd_ecoff_styp_to_sec_flags (abfd, hdr, name, section, flags_ptr)
       bfd *abfd ATTRIBUTE_UNUSED;
       PTR hdr;
       const char *name ATTRIBUTE_UNUSED;
       asection *section ATTRIBUTE_UNUSED;
+      flagword * flags_ptr;
  {
    struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
    long styp_flags = internal_s->s_flags;
!   flagword sec_flags = 0;
  
    if (styp_flags & STYP_NOLOAD)
      sec_flags |= SEC_NEVER_LOAD;
*************** _bfd_ecoff_styp_to_sec_flags (abfd, hdr,
*** 422,450 ****
      }
    else if ((styp_flags & STYP_BSS)
  	   || (styp_flags & STYP_SBSS))
!     {
!       sec_flags |= SEC_ALLOC;
!     }
    else if ((styp_flags & STYP_INFO) || styp_flags == STYP_COMMENT)
!     {
!       sec_flags |= SEC_NEVER_LOAD;
!     }
    else if ((styp_flags & STYP_LITA)
  	   || (styp_flags & STYP_LIT8)
  	   || (styp_flags & STYP_LIT4))
!     {
!       sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC | SEC_READONLY;
!     }
    else if (styp_flags & STYP_ECOFF_LIB)
!     {
!       sec_flags |= SEC_COFF_SHARED_LIBRARY;
!     }
    else
!     {
!       sec_flags |= SEC_ALLOC | SEC_LOAD;
!     }
  
!   return sec_flags;
  }
  \f
  /* Read in the symbolic header for an ECOFF object file.  */
--- 423,442 ----
      }
    else if ((styp_flags & STYP_BSS)
  	   || (styp_flags & STYP_SBSS))
!     sec_flags |= SEC_ALLOC;
    else if ((styp_flags & STYP_INFO) || styp_flags == STYP_COMMENT)
!     sec_flags |= SEC_NEVER_LOAD;
    else if ((styp_flags & STYP_LITA)
  	   || (styp_flags & STYP_LIT8)
  	   || (styp_flags & STYP_LIT4))
!     sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC | SEC_READONLY;
    else if (styp_flags & STYP_ECOFF_LIB)
!     sec_flags |= SEC_COFF_SHARED_LIBRARY;
    else
!     sec_flags |= SEC_ALLOC | SEC_LOAD;
  
!   * flags_ptr = sec_flags;
!   return true;
  }
  \f
  /* Read in the symbolic header for an ECOFF object file.  */

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

end of thread, other threads:[~2001-06-12 10:48 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-05-29 23:50 "Warning: size of symbol FOO changed from X to Y in OBJ" Philip Blundell
2001-05-30  0:01 ` Geoff Keating
2001-05-30 10:13 ` Ian Lance Taylor
2001-05-30 16:56   ` amodra
2001-05-30 19:26     ` Ian Lance Taylor
2001-05-30 21:02       ` H . J . Lu
2001-05-30 23:55         ` Ian Lance Taylor
2001-05-31  0:14           ` H . J . Lu
2001-05-31  0:26             ` Ian Lance Taylor
2001-05-31  9:35               ` H . J . Lu
2001-05-31 10:33                 ` Ian Lance Taylor
2001-05-31 11:23                   ` H . J . Lu
2001-05-31  1:49             ` Nick Clifton
2001-05-31 11:57               ` H . J . Lu
2001-05-31 12:08                 ` Ian Lance Taylor
2001-06-12 10:48           ` Nick Clifton

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).