public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* mainline ld on mingw32/pe is broken, returns 1 without error.
@ 2004-06-27  1:29 Aaron W. LaFramboise
  2004-06-27  4:06 ` Alan Modra
  0 siblings, 1 reply; 8+ messages in thread
From: Aaron W. LaFramboise @ 2004-06-27  1:29 UTC (permalink / raw)
  To: binutils

Since I updated binutils from mainline today, ld on i686-pc-mingw32 no
longer works.  I am not sure when I had last synched and tested, but
probably no longer than a month or two.

This is a trivial example linking a hello world application that worked
before, and fails now.

ld -o hello.exe
c:/aaronwl/cs/env/mingw-3.4.0-2.15-3.3/bin/../lib/gcc/i686-pc-mingw32/3.4.0/../../../crt2.o
-Lc:/aaronwl/cs/env/mingw-3.4.0-2.15-3.3/bin/../lib/gcc/i686-pc-mingw32/3.4.0
hello.o -lmingw32 -lgcc -lmsvcrt -lkernel32

It prints absolutely no messages, but exits with code 1, and does not
leave output files.

How should I begin to debug this?  Any ideas what change caused this?

I suppose I need to start testing binutils more regularly. :)

Aaron W. LaFramboise

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

* Re: mainline ld on mingw32/pe is broken, returns 1 without error.
  2004-06-27  1:29 mainline ld on mingw32/pe is broken, returns 1 without error Aaron W. LaFramboise
@ 2004-06-27  4:06 ` Alan Modra
  2004-06-27  4:32   ` Aaron W. LaFramboise
  0 siblings, 1 reply; 8+ messages in thread
From: Alan Modra @ 2004-06-27  4:06 UTC (permalink / raw)
  To: Aaron W. LaFramboise; +Cc: binutils

On Sat, Jun 26, 2004 at 08:29:15PM -0500, Aaron W. LaFramboise wrote:
> ld -o hello.exe
> c:/aaronwl/cs/env/mingw-3.4.0-2.15-3.3/bin/../lib/gcc/i686-pc-mingw32/3.4.0/../../../crt2.o
> -Lc:/aaronwl/cs/env/mingw-3.4.0-2.15-3.3/bin/../lib/gcc/i686-pc-mingw32/3.4.0
> hello.o -lmingw32 -lgcc -lmsvcrt -lkernel32
> 
> It prints absolutely no messages, but exits with code 1, and does not
> leave output files.
> 
> How should I begin to debug this?  Any ideas what change caused this?

There's a good chance this is due to my 2004-06-24 section sizing
change.  Build binutils from source just before this change went in, and
see if ld is good.  Assuming it is, compare hello.exe before and after
the patch.  Any change is suspicious, apart from the silly timestamp in
pe files.  objdump will let you look at section sizes..

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

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

* Re: mainline ld on mingw32/pe is broken, returns 1 without error.
  2004-06-27  4:06 ` Alan Modra
@ 2004-06-27  4:32   ` Aaron W. LaFramboise
  2004-06-27 11:49     ` Alan Modra
  0 siblings, 1 reply; 8+ messages in thread
From: Aaron W. LaFramboise @ 2004-06-27  4:32 UTC (permalink / raw)
  To: Alan Modra; +Cc: binutils

Alan Modra wrote:

> On Sat, Jun 26, 2004 at 08:29:15PM -0500, Aaron W. LaFramboise wrote:
> 
>>ld -o hello.exe
>>c:/aaronwl/cs/env/mingw-3.4.0-2.15-3.3/bin/../lib/gcc/i686-pc-mingw32/3.4.0/../../../crt2.o
>>-Lc:/aaronwl/cs/env/mingw-3.4.0-2.15-3.3/bin/../lib/gcc/i686-pc-mingw32/3.4.0
>>hello.o -lmingw32 -lgcc -lmsvcrt -lkernel32
>>
>>It prints absolutely no messages, but exits with code 1, and does not
>>leave output files.
>>
>>How should I begin to debug this?  Any ideas what change caused this?
> 
> 
> There's a good chance this is due to my 2004-06-24 section sizing
> change.  Build binutils from source just before this change went in, and
> see if ld is good.  Assuming it is, compare hello.exe before and after
> the patch.  Any change is suspicious, apart from the silly timestamp in
> pe files.  objdump will let you look at section sizes..
> 

When I reverted my binutils tree to June 23 from today, this bug went
away.  When I set it to June 24, it came back.
http://sources.redhat.com/ml/binutils-cvs/2004-06/msg00088.html
http://sources.redhat.com/ml/binutils/2004-06/msg00210.html

I can't compare the two files, because the buggy ld does not emit
hello.exe at all.  It just silently exits with exit code as 1.  Is there
some set of flags I should pass that would help trace ld's execution?
ld -t seems to indicate it is reading from all of the files it should,
but I can't say for sure.

Aaron W. LaFramboise

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

* Re: mainline ld on mingw32/pe is broken, returns 1 without error.
  2004-06-27  4:32   ` Aaron W. LaFramboise
@ 2004-06-27 11:49     ` Alan Modra
  2004-06-28  5:01       ` Aaron W. LaFramboise
  0 siblings, 1 reply; 8+ messages in thread
From: Alan Modra @ 2004-06-27 11:49 UTC (permalink / raw)
  To: Aaron W. LaFramboise; +Cc: binutils

On Sat, Jun 26, 2004 at 11:32:26PM -0500, Aaron W. LaFramboise wrote:
> I can't compare the two files, because the buggy ld does not emit
> hello.exe at all.  It just silently exits with exit code as 1.

Sorry, I missed noticing that you said this before.

>  Is there
> some set of flags I should pass that would help trace ld's execution?
> ld -t seems to indicate it is reading from all of the files it should,
> but I can't say for sure.

No, there's no easy way to debug this.  I'd fire up gdb and see if we
get to ldwrite.  I'm guessing that the problem is in bfd_final_link,
so that would mean tracing through _bfd_coff_final_link.  Would you
mind taking a look?  If that doesn't sound easy, could you please tar
and gzip the set of objects and libraries involved in the link and
send them to me.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

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

* Re: mainline ld on mingw32/pe is broken, returns 1 without error.
  2004-06-27 11:49     ` Alan Modra
@ 2004-06-28  5:01       ` Aaron W. LaFramboise
       [not found]         ` <20040628051054.GR3469@bubble.modra.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Aaron W. LaFramboise @ 2004-06-28  5:01 UTC (permalink / raw)
  To: Alan Modra; +Cc: binutils

Alan Modra wrote:
> No, there's no easy way to debug this.  I'd fire up gdb and see if we
> get to ldwrite.  I'm guessing that the problem is in bfd_final_link,
> so that would mean tracing through _bfd_coff_final_link.  Would you
> mind taking a look?  If that doesn't sound easy, could you please tar
> and gzip the set of objects and libraries involved in the link and
> send them to me.

Well, I've found where the error is coming from, but I have no idea why. :)

_bfd_coff_link_input_bfd seems to be asking for more data than is in the
file.  See the following:

#0  cache_bread (abfd=0x3df0c8, buf=0x8904e0, nbytes=480930)
    at ../../../../../src/cvs/src/bfd/cache.c:100
#1  0x004326f1 in bfd_bread (ptr=0x8904e0, size=480930, abfd=0x3df0c8)
    at ../../../../../src/cvs/src/bfd/bfdio.c:129
#2  0x0043236d in _bfd_generic_get_section_contents (abfd=0x3df0c8,
    section=0x6d76ec, location=0x8904e0, offset=0, count=480930)
    at ../../../../../src/cvs/src/bfd/libbfd.c:706
#3  0x00426310 in bfd_get_section_contents (abfd=0x3df0c8,
section=0x6d76ec,
    location=0x8904e0, offset=0, count=480930)
    at ../../../../../src/cvs/src/bfd/section.c:1355
#4  0x0044c080 in _bfd_coff_link_input_bfd (finfo=0x22fe50,
input_bfd=0x3df0c8)
    at ../../../../../src/cvs/src/bfd/cofflink.c:2308
#5  0x0044934d in _bfd_coff_final_link (abfd=0x3dced8, info=<incomplete
type>)
    at ../../../../../src/cvs/src/bfd/cofflink.c:899
#6  0x00414987 in ldwrite () at ../../../../../src/cvs/src/ld/ldwrite.c:554
#7  0x00411dcb in main (argc=12, argv=0x3d2710)
    at ../../../../../src/cvs/src/ld/ldmain.c:481

96        nread = fread (buf, 1, nbytes, bfd_cache_lookup (abfd));
97        /* Set bfd_error if we did not read as much data as we
expected.  If
98           the read failed due to an error set the bfd_error_system_call,
99           else set bfd_error_file_truncated.  */
100       if (nread < nbytes && ferror (bfd_cache_lookup (abfd)))
101         {
102           bfd_set_error (bfd_error_system_call);
103           return -1;
104         }

nread = 182131
nbytes = 480930

There is a second latent bug here also.  The comment indicates that
bfd_error_file_truncated should be set in this case, and as near as I
can tell, it is not being set, which is what is causing the mysterious
silent failure.  This can be easily fixed.

On the other hand, I have no idea how to figure out what is actually
causing the size requested to be wrong.

What next? :)

Aaron W. LaFramboise

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

* Re: mainline ld on mingw32/pe is broken, returns 1 without error.
       [not found]           ` <40DFA9A4.3010303@aaronwl.com>
@ 2004-06-28  6:26             ` Alan Modra
  2004-06-28 13:34               ` Alan Modra
  0 siblings, 1 reply; 8+ messages in thread
From: Alan Modra @ 2004-06-28  6:26 UTC (permalink / raw)
  To: Aaron W. LaFramboise; +Cc: binutils

On Mon, Jun 28, 2004 at 12:16:20AM -0500, Aaron W. LaFramboise wrote:
> (gdb) p *section
> $2 = {name = 0x4b9f45 ".stabstr", id = 21, index = 5, next = 0x0,
>   flags = 66064, user_set_vma = 0, linker_mark = 1, linker_has_input = 0,
>   gc_mark = 0, segment_mark = 0, sec_info_type = 0, use_rela_p = 0,
>   has_tls_reloc = 0, has_gp_reloc = 0, need_finalize_relax = 0,
>   reloc_done = 0, vma = 0, lma = 0, size = 480930, rawsize = 0,
>   output_offset = 0, output_section = 0x3de92c, alignment_power = 0,
>   relocation = 0x0, orelocation = 0x0, reloc_count = 0, filepos = 0,
>   rel_filepos = 0, line_filepos = 0, userdata = 0x0, contents = 0x0,
>   lineno = 0x0, lineno_count = 0, entsize = 0, comdat = 0x0,
>   kept_section = 0x0, moving_line_filepos = 0, target_index = 0,
>   used_by_bfd = 0x0, constructor_chain = 0x0, owner = 0x3df0b8,
>   symbol = 0x6d6ae8, symbol_ptr_ptr = 0x6d7768, link_order_head = 0x0,
>   link_order_tail = 0x0}

Sigh.  This has to be the stabstr section created at stabs.c:248 (if
the section came from an input file, it wouldn't have filepos == 0).

It looks like the linker relies on raw size being zero for these
sections.  ie. places where I do o->rawsize ? o->rawsize : o->size
are broken.  The fix will be to set rawsize for all input sections,
and remove all the places I test rawsize.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

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

* Re: mainline ld on mingw32/pe is broken, returns 1 without error.
  2004-06-28  6:26             ` Alan Modra
@ 2004-06-28 13:34               ` Alan Modra
  2004-06-28 22:14                 ` Aaron W. LaFramboise
  0 siblings, 1 reply; 8+ messages in thread
From: Alan Modra @ 2004-06-28 13:34 UTC (permalink / raw)
  To: Aaron W. LaFramboise, binutils

On Mon, Jun 28, 2004 at 03:56:18PM +0930, Alan Modra wrote:
> Sigh.  This has to be the stabstr section created at stabs.c:248 (if
> the section came from an input file, it wouldn't have filepos == 0).
> 
> It looks like the linker relies on raw size being zero for these
> sections.  ie. places where I do o->rawsize ? o->rawsize : o->size
> are broken.  The fix will be to set rawsize for all input sections,
> and remove all the places I test rawsize.

This should fix the stabs breakage.  I decided not to pursue the idea of
setting rawsize when reading sections from disk.  The fewer places that
need to touch rawsize, the better.

bfd/ChangeLog
	* bfd-in.h (struct stab_info): Move from stabs.c.
	* stabs.c (struct stab_link_includes_table): Delete.
	(stab_link_includes_lookup): Delete.
	(_bfd_write_section_stabs, _bfd_write_stab_strings): Remove one
	level of indirection from sinfo parm.
	(_bfd_link_section_stabs): Likewise.  Set SEC_LINKER_CREATED on
	stabstr section.  Adjust hash table accesses.
	* coff-ppc.c (ppc_bfd_coff_final_link): Do include rawsize in contents
	alloc.  Adjust stab_info test.
	* cofflink.c (_bfd_coff_link_hash_table_init): Clear stab_info.
	(_bfd_coff_final_link): Adjust stab_info test.
	(_bfd_coff_link_input_bfd): Ignore SEC_LINKER_CREATED sections.
	* elf-bfd.h (struct elf_link_hash_table): Include struct stab_info
	in place.
	* libcoff-in.h (struct coff_link_hash_table): Likewise.
	* elf.c (_bfd_elf_link_hash_table_init): Clear stab_info.
	* elflink.c (bfd_elf_final_link): Don't attempt to link linker created
	stabstr section.  Adjust stab_info test.
	* libbfd-in.h (_bfd_link_section_stabs, _bfd_write_section_stabs)
	(_bfd_write_stab_strings): Adjust prototypes.
	* libbfd.h: Regenerate.
	* libcoff.h: Regenerate.
	* bfd-in2.h: Regenerate.

Index: bfd/bfd-in.h
===================================================================
RCS file: /cvs/src/src/bfd/bfd-in.h,v
retrieving revision 1.83
diff -u -p -r1.83 bfd-in.h
--- bfd/bfd-in.h	24 Jun 2004 04:46:14 -0000	1.83
+++ bfd/bfd-in.h	28 Jun 2004 13:15:59 -0000
@@ -439,6 +439,19 @@ extern void bfd_hash_traverse
    this size.  */
 extern void bfd_hash_set_default_size (bfd_size_type);
 
+/* This structure is used to keep track of stabs in sections
+   information while linking.  */
+
+struct stab_info
+{
+  /* A hash table used to hold stabs strings.  */
+  struct bfd_strtab_hash *strings;
+  /* The header file hash table.  */
+  struct bfd_hash_table includes;
+  /* The first .stabstr section.  */
+  struct bfd_section *stabstr;
+};
+
 #define COFF_SWAP_TABLE (void *) &bfd_coff_std_swap_table
 
 /* User program access to BFD facilities.  */
Index: bfd/coff-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/coff-ppc.c,v
retrieving revision 1.20
diff -u -p -r1.20 coff-ppc.c
--- bfd/coff-ppc.c	24 Jun 2004 04:46:15 -0000	1.20
+++ bfd/coff-ppc.c	28 Jun 2004 13:16:06 -0000
@@ -2328,6 +2328,8 @@ ppc_bfd_coff_final_link (abfd, info)
 	      if (info->relocatable)
 		o->reloc_count += sec->reloc_count;
 
+	      if (sec->rawsize > max_contents_size)
+		max_contents_size = sec->rawsize;
 	      if (sec->size > max_contents_size)
 		max_contents_size = sec->size;
 	      if (sec->lineno_count > max_lineno_count)
@@ -2663,7 +2665,7 @@ ppc_bfd_coff_final_link (abfd, info)
     }
 
   /* If we have optimized stabs strings, output them.  */
-  if (coff_hash_table (info)->stab_info != NULL)
+  if (coff_hash_table (info)->stab_info.stabstr != NULL)
     {
       if (! _bfd_write_stab_strings (abfd, &coff_hash_table (info)->stab_info))
 	return FALSE;
Index: bfd/cofflink.c
===================================================================
RCS file: /cvs/src/src/bfd/cofflink.c,v
retrieving revision 1.44
diff -u -p -r1.44 cofflink.c
--- bfd/cofflink.c	24 Jun 2004 04:46:16 -0000	1.44
+++ bfd/cofflink.c	28 Jun 2004 13:16:08 -0000
@@ -96,7 +96,7 @@ _bfd_coff_link_hash_table_init (struct c
 								   struct bfd_hash_table *,
 								   const char *))
 {
-  table->stab_info = NULL;
+  memset (&table->stab_info, 0, sizeof (table->stab_info));
   return _bfd_link_hash_table_init (&table->root, abfd, newfunc);
 }
 
@@ -1082,7 +1082,7 @@ _bfd_coff_final_link (bfd *abfd,
     }
 
   /* If we have optimized stabs strings, output them.  */
-  if (coff_hash_table (info)->stab_info != NULL)
+  if (coff_hash_table (info)->stab_info.stabstr != NULL)
     {
       if (! _bfd_write_stab_strings (abfd, &coff_hash_table (info)->stab_info))
 	return FALSE;
@@ -2282,6 +2282,9 @@ _bfd_coff_link_input_bfd (struct coff_fi
 	/* This section was omitted from the link.  */
 	continue;
 
+      if ((o->flags & SEC_LINKER_CREATED) != 0)
+	continue;
+
       if ((o->flags & SEC_HAS_CONTENTS) == 0
 	  || (o->size == 0 && (o->flags & SEC_RELOC) == 0))
 	{
Index: bfd/elf-bfd.h
===================================================================
RCS file: /cvs/src/src/bfd/elf-bfd.h,v
retrieving revision 1.143
diff -u -p -r1.143 elf-bfd.h
--- bfd/elf-bfd.h	21 Jun 2004 14:45:41 -0000	1.143
+++ bfd/elf-bfd.h	28 Jun 2004 13:16:14 -0000
@@ -356,12 +356,12 @@ struct elf_link_hash_table
   /* The _GLOBAL_OFFSET_TABLE_ symbol.  */
   struct elf_link_hash_entry *hgot;
 
-  /* A pointer to information used to link stabs in sections.  */
-  void *stab_info;
-
   /* A pointer to information used to merge SEC_MERGE sections.  */
   void *merge_info;
 
+  /* Used to link stabs in sections.  */
+  struct stab_info stab_info;
+
   /* Used by eh_frame code when editing .eh_frame.  */
   struct eh_frame_hdr_info eh_info;
 
Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.231
diff -u -p -r1.231 elf.c
--- bfd/elf.c	24 Jun 2004 04:46:18 -0000	1.231
+++ bfd/elf.c	28 Jun 2004 13:16:19 -0000
@@ -1466,8 +1466,8 @@ _bfd_elf_link_hash_table_init
   table->bucketcount = 0;
   table->needed = NULL;
   table->hgot = NULL;
-  table->stab_info = NULL;
   table->merge_info = NULL;
+  memset (&table->stab_info, 0, sizeof (table->stab_info));
   memset (&table->eh_info, 0, sizeof (table->eh_info));
   table->dynlocal = NULL;
   table->runpath = NULL;
Index: bfd/elflink.c
===================================================================
RCS file: /cvs/src/src/bfd/elflink.c,v
retrieving revision 1.74
diff -u -p -r1.74 elflink.c
--- bfd/elflink.c	24 Jun 2004 04:46:22 -0000	1.74
+++ bfd/elflink.c	28 Jun 2004 13:16:53 -0000
@@ -4124,7 +4124,7 @@ elf_link_add_object_symbols (bfd *abfd, 
 
 		secdata = elf_section_data (stab);
 		if (! _bfd_link_section_stabs (abfd,
-					       & hash_table->stab_info,
+					       &hash_table->stab_info,
 					       stab, stabstr,
 					       &secdata->sec_info,
 					       &string_offset))
@@ -8001,6 +8001,8 @@ bfd_elf_final_link (bfd *abfd, struct bf
 		 created by _bfd_elf_link_create_dynamic_sections.  */
 	      continue;
 	    }
+	  if (elf_hash_table (info)->stab_info.stabstr == o)
+	    continue;
 	  if (elf_hash_table (info)->eh_info.hdr_sec == o)
 	    continue;
 	  if ((elf_section_data (o->output_section)->this_hdr.sh_type
@@ -8036,7 +8038,7 @@ bfd_elf_final_link (bfd *abfd, struct bf
     }
 
   /* If we have optimized stabs strings, output them.  */
-  if (elf_hash_table (info)->stab_info != NULL)
+  if (elf_hash_table (info)->stab_info.stabstr != NULL)
     {
       if (! _bfd_write_stab_strings (abfd, &elf_hash_table (info)->stab_info))
 	goto error_return;
Index: bfd/libbfd-in.h
===================================================================
RCS file: /cvs/src/src/bfd/libbfd-in.h,v
retrieving revision 1.37
diff -u -p -r1.37 libbfd-in.h
--- bfd/libbfd-in.h	24 Jun 2004 04:46:24 -0000	1.37
+++ bfd/libbfd-in.h	28 Jun 2004 13:17:00 -0000
@@ -498,7 +498,8 @@ extern bfd_reloc_status_type _bfd_reloca
 /* Link stabs in sections in the first pass.  */
 
 extern bfd_boolean _bfd_link_section_stabs
-  (bfd *, void **, asection *, asection *, void **, bfd_size_type *);
+  (bfd *, struct stab_info *, asection *, asection *, void **,
+   bfd_size_type *);
 
 /* Eliminate stabs for discarded functions and symbols.  */
 extern bfd_boolean _bfd_discard_section_stabs
@@ -507,12 +508,12 @@ extern bfd_boolean _bfd_discard_section_
 /* Write out the .stab section when linking stabs in sections.  */
 
 extern bfd_boolean _bfd_write_section_stabs
-  (bfd *, void **, asection *, void **, bfd_byte *);
+  (bfd *, struct stab_info *, asection *, void **, bfd_byte *);
 
 /* Write out the .stabstr string table when linking stabs in sections.  */
 
 extern bfd_boolean _bfd_write_stab_strings
-  (bfd *, void **);
+  (bfd *, struct stab_info *);
 
 /* Find an offset within a .stab section when linking stabs in
    sections.  */
Index: bfd/libcoff-in.h
===================================================================
RCS file: /cvs/src/src/bfd/libcoff-in.h,v
retrieving revision 1.20
diff -u -p -r1.20 libcoff-in.h
--- bfd/libcoff-in.h	20 Oct 2003 14:38:39 -0000	1.20
+++ bfd/libcoff-in.h	28 Jun 2004 13:17:01 -0000
@@ -276,7 +276,7 @@ struct coff_link_hash_table
 {
   struct bfd_link_hash_table root;
   /* A pointer to information used to link stabs in sections.  */
-  PTR stab_info;
+  struct stab_info stab_info;
 };
 
 /* Look up an entry in a COFF linker hash table.  */
Index: bfd/stabs.c
===================================================================
RCS file: /cvs/src/src/bfd/stabs.c,v
retrieving revision 1.19
diff -u -p -r1.19 stabs.c
--- bfd/stabs.c	24 Jun 2004 04:46:26 -0000	1.19
+++ bfd/stabs.c	28 Jun 2004 13:17:05 -0000
@@ -48,13 +48,6 @@
 #define VALOFF (8)
 #define STABSIZE (12)
 
-/* A hash table used for header files with N_BINCL entries.  */
-
-struct stab_link_includes_table
-{
-  struct bfd_hash_table root;
-};
-
 /* A linked list of totals that we have found for a particular header
    file.  A total is a unique identifier for a particular BINCL...EINCL
    sequence of STABs that can be used to identify duplicate sequences.
@@ -80,12 +73,6 @@ struct stab_link_includes_entry
   struct stab_link_includes_totals *totals;
 };
 
-/* Look up an entry in an the header file hash table.  */
-
-#define stab_link_includes_lookup(table, string, create, copy) \
-  ((struct stab_link_includes_entry *) \
-   bfd_hash_lookup (&(table)->root, (string), (create), (copy)))
-
 /* This structure is used to hold a list of N_BINCL symbols, some of
    which might be converted into N_EXCL symbols.  */
 
@@ -124,19 +111,6 @@ struct stab_section_info
   bfd_size_type stridxs[1];
 };
 
-/* This structure is used to keep track of stabs in sections
-   information while linking.  */
-
-struct stab_info
-{
-  /* A hash table used to hold stabs strings.  */
-  struct bfd_strtab_hash *strings;
-  /* The header file hash table.  */
-  struct stab_link_includes_table includes;
-  /* The first .stabstr section.  */
-  asection *stabstr;
-};
-
 static struct bfd_hash_entry *stab_link_includes_newfunc
   PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
 \f
@@ -176,16 +150,15 @@ stab_link_includes_newfunc (entry, table
    pass of the linker.  */
 
 bfd_boolean
-_bfd_link_section_stabs (abfd, psinfo, stabsec, stabstrsec, psecinfo, pstring_offset)
+_bfd_link_section_stabs (abfd, sinfo, stabsec, stabstrsec, psecinfo, pstring_offset)
      bfd *abfd;
-     PTR *psinfo;
+     struct stab_info *sinfo;
      asection *stabsec;
      asection *stabstrsec;
      PTR *psecinfo;
      bfd_size_type *pstring_offset;
 {
   bfd_boolean first;
-  struct stab_info *sinfo;
   bfd_size_type count, amt;
   struct stab_section_info *secinfo;
   bfd_byte *stabbuf = NULL;
@@ -227,30 +200,26 @@ _bfd_link_section_stabs (abfd, psinfo, s
 
   first = FALSE;
 
-  if (*psinfo == NULL)
+  if (sinfo->stabstr == NULL)
     {
       /* Initialize the stabs information we need to keep track of.  */
       first = TRUE;
-      amt = sizeof (struct stab_info);
-      *psinfo = (PTR) bfd_alloc (abfd, amt);
-      if (*psinfo == NULL)
-	goto error_return;
-      sinfo = (struct stab_info *) *psinfo;
       sinfo->strings = _bfd_stringtab_init ();
       if (sinfo->strings == NULL)
 	goto error_return;
       /* Make sure the first byte is zero.  */
       (void) _bfd_stringtab_add (sinfo->strings, "", TRUE, TRUE);
-      if (! bfd_hash_table_init_n (&sinfo->includes.root,
+      if (! bfd_hash_table_init_n (&sinfo->includes,
 				   stab_link_includes_newfunc,
 				   251))
 	goto error_return;
       sinfo->stabstr = bfd_make_section_anyway (abfd, ".stabstr");
-      sinfo->stabstr->flags |= SEC_HAS_CONTENTS | SEC_READONLY | SEC_DEBUGGING;
+      if (sinfo->stabstr == NULL)
+	goto error_return;
+      sinfo->stabstr->flags |= (SEC_HAS_CONTENTS | SEC_READONLY
+				| SEC_DEBUGGING | SEC_LINKER_CREATED);
     }
 
-  sinfo = (struct stab_info *) *psinfo;
-
   /* Initialize the information we are going to store for this .stab
      section.  */
 
@@ -411,8 +380,8 @@ _bfd_link_section_stabs (abfd, psinfo, s
 
 	  /* If we have already included a header file with the same
 	     value, then replaced this one with an N_EXCL symbol.  */
-	  incl_entry = stab_link_includes_lookup (&sinfo->includes, string,
-						  TRUE, TRUE);
+	  incl_entry = (struct stab_link_includes_entry * )
+	    bfd_hash_lookup (&sinfo->includes, string, TRUE, TRUE);
 	  if (incl_entry == NULL)
 	    goto error_return;
 
@@ -439,7 +408,7 @@ _bfd_link_section_stabs (abfd, psinfo, s
 	      /* This is the first time we have seen this header file
 		 with this set of stabs strings.  */
 	      t = ((struct stab_link_includes_totals *)
-		   bfd_hash_allocate (&sinfo->includes.root, sizeof *t));
+		   bfd_hash_allocate (&sinfo->includes, sizeof *t));
 	      if (t == NULL)
 		goto error_return;
 	      t->sum_chars = sum_chars;
@@ -718,20 +687,18 @@ _bfd_discard_section_stabs (abfd, stabse
    contents.  */
 
 bfd_boolean
-_bfd_write_section_stabs (output_bfd, psinfo, stabsec, psecinfo, contents)
+_bfd_write_section_stabs (output_bfd, sinfo, stabsec, psecinfo, contents)
      bfd *output_bfd;
-     PTR *psinfo;
+     struct stab_info *sinfo;
      asection *stabsec;
      PTR *psecinfo;
      bfd_byte *contents;
 {
-  struct stab_info *sinfo;
   struct stab_section_info *secinfo;
   struct stab_excl_list *e;
   bfd_byte *sym, *tosym, *symend;
   bfd_size_type *pstridx;
 
-  sinfo = (struct stab_info *) *psinfo;
   secinfo = (struct stab_section_info *) *psecinfo;
 
   if (secinfo == NULL)
@@ -792,17 +759,10 @@ _bfd_write_section_stabs (output_bfd, ps
 /* Write out the .stabstr section.  */
 
 bfd_boolean
-_bfd_write_stab_strings (output_bfd, psinfo)
+_bfd_write_stab_strings (output_bfd, sinfo)
      bfd *output_bfd;
-     PTR *psinfo;
+     struct stab_info *sinfo;
 {
-  struct stab_info *sinfo;
-
-  sinfo = (struct stab_info *) *psinfo;
-
-  if (sinfo == NULL)
-    return TRUE;
-
   if (bfd_is_abs_section (sinfo->stabstr->output_section))
     {
       /* The section was discarded from the link.  */
@@ -824,7 +784,7 @@ _bfd_write_stab_strings (output_bfd, psi
 
   /* We no longer need the stabs information.  */
   _bfd_stringtab_free (sinfo->strings);
-  bfd_hash_table_free (&sinfo->includes.root);
+  bfd_hash_table_free (&sinfo->includes);
 
   return TRUE;
 }
Index: opcodes/ppc-opc.c
===================================================================
RCS file: /cvs/src/src/opcodes/ppc-opc.c,v
retrieving revision 1.72
diff -u -p -r1.72 ppc-opc.c
--- opcodes/ppc-opc.c	26 Jun 2004 08:32:12 -0000	1.72
+++ opcodes/ppc-opc.c	28 Jun 2004 13:17:54 -0000
@@ -998,11 +998,22 @@ insert_fxm (unsigned long insn,
 	    int dialect,
 	    const char **errmsg)
 {
+  /* If we're handling the mfocrf and mtocrf insns ensure that exactly
+     one bit of the mask field is set.  */
+  if ((insn & (1 << 20)) != 0)
+    {
+      if (value == 0 || (value & -value) != value)
+	{
+	  *errmsg = _("invalid mask field");
+	  value = 0;
+	}
+    }
+
   /* If the optional field on mfcr is missing that means we want to use
      the old form of the instruction that moves the whole cr.  In that
      case we'll have VALUE zero.  There doesn't seem to be a way to
      distinguish this from the case where someone writes mfcr %r3,0.  */
-  if (value == 0)
+  else if (value == 0)
     ;
 
   /* If only one bit of the FXM field is set, we can use the new form
@@ -1028,7 +1039,7 @@ insert_fxm (unsigned long insn,
 
 static long
 extract_fxm (unsigned long insn,
-	     int dialect,
+	     int dialect ATTRIBUTE_UNUSED,
 	     int *invalid)
 {
   long mask = (insn >> 12) & 0xff;
@@ -1036,14 +1047,9 @@ extract_fxm (unsigned long insn,
   /* Is this a Power4 insn?  */
   if ((insn & (1 << 20)) != 0)
     {
-      if ((dialect & PPC_OPCODE_POWER4) == 0)
+      /* Exactly one bit of MASK should be set.  */
+      if (mask == 0 || (mask & -mask) != mask)
 	*invalid = 1;
-      else
-	{
-	  /* Exactly one bit of MASK should be set.  */
-	  if (mask == 0 || (mask & -mask) != mask)
-	    *invalid = 1;
-	}
     }
 
   /* Check that non-power4 form of mfcr has a zero MASK.  */
@@ -1681,11 +1687,12 @@ extract_tbr (unsigned long insn,
 #define XS_MASK XS (0x3f, 0x1ff, 1)
 
 /* A mask for the FXM version of an XFX form instruction.  */
-#define XFXFXM_MASK (X_MASK | (1 << 11))
+#define XFXFXM_MASK (X_MASK | (1 << 11) | (1 << 20))
 
 /* An XFX form instruction with the FXM field filled in.  */
-#define XFXM(op, xop, fxm) \
-  (X ((op), (xop)) | ((((unsigned long)(fxm)) & 0xff) << 12))
+#define XFXM(op, xop, fxm, p4) \
+  (X ((op), (xop)) | ((((unsigned long)(fxm)) & 0xff) << 12) \
+   | ((unsigned long)(p4) << 20))
 
 /* An XFX form instruction with the SPR field filled in.  */
 #define XSPR(op, xop, spr) \
@@ -3227,6 +3234,7 @@ const struct powerpc_opcode powerpc_opco
 { "iseleq",  X(31,79),      X_MASK,	PPCISEL,	{ RT, RA, RB } },
 { "isel",    XISEL(31,15),  XISEL_MASK,	PPCISEL,	{ RT, RA, RB, CRB } },
 
+{ "mfocrf",  XFXM(31,19,0,1), XFXFXM_MASK, COM,		{ RT, FXM } },
 { "mfcr",    X(31,19),	XRARB_MASK,	NOPOWER4,	{ RT } },
 { "mfcr",    X(31,19),	XFXFXM_MASK,	POWER4,		{ RT, FXM4 } },
 
@@ -3382,7 +3390,8 @@ const struct powerpc_opcode powerpc_opco
 
 { "dcbtstlse",X(31,142),X_MASK,		PPCCHLK64,	{ CT, RA, RB }},
 
-{ "mtcr",    XFXM(31,144,0xff), XRARB_MASK, COM,	{ RS }},
+{ "mtocrf",  XFXM(31,144,0,1), XFXFXM_MASK, COM,	{ FXM, RS } },
+{ "mtcr",    XFXM(31,144,0xff,0), XRARB_MASK, COM,	{ RS }},
 { "mtcrf",   X(31,144),	XFXFXM_MASK,	COM,		{ FXM, RS } },
 
 { "mtmsr",   X(31,146),	XRARB_MASK,	COM,		{ RS } },

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

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

* Re: mainline ld on mingw32/pe is broken, returns 1 without error.
  2004-06-28 13:34               ` Alan Modra
@ 2004-06-28 22:14                 ` Aaron W. LaFramboise
  0 siblings, 0 replies; 8+ messages in thread
From: Aaron W. LaFramboise @ 2004-06-28 22:14 UTC (permalink / raw)
  To: Alan Modra; +Cc: binutils

Alan Modra wrote:
> This should fix the stabs breakage.  I decided not to pursue the idea of
> setting rawsize when reading sections from disk.  The fewer places that
> need to touch rawsize, the better.

This fix worked.  Thanks!

Aaron W. LaFramboise

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

end of thread, other threads:[~2004-06-28 22:14 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-27  1:29 mainline ld on mingw32/pe is broken, returns 1 without error Aaron W. LaFramboise
2004-06-27  4:06 ` Alan Modra
2004-06-27  4:32   ` Aaron W. LaFramboise
2004-06-27 11:49     ` Alan Modra
2004-06-28  5:01       ` Aaron W. LaFramboise
     [not found]         ` <20040628051054.GR3469@bubble.modra.org>
     [not found]           ` <40DFA9A4.3010303@aaronwl.com>
2004-06-28  6:26             ` Alan Modra
2004-06-28 13:34               ` Alan Modra
2004-06-28 22:14                 ` Aaron W. LaFramboise

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