Re: [incomplete patch] Get objdump to report exception tables for ARM/SH4 correctly

2008-03-29 Thread Danny Backx
This has been on my todo-list for far too long, apologies.

I've tried to tackle the conditional compilation part, and would like
your renewed input on it, I may have missed some points. Naming for
instance.

Diffs in the attachment are relative to the cegcc svn, I've checked and
they patch cleanly in a binutils 2.18 tree.

So, please tell me what I'm missing and I'll change my patch.

Danny

On Mon, 2007-08-06 at 16:22 +0100, Nick Clifton wrote:
> Hi Danny,
> 
> 
> > 2. Cleanup in my_symbol_for_address. There's none now. Should there be?
> 
> Yes. :-)
> 
> Also it looks like my_symbol_for_address is going to quite slow for large 
> symbol tables.  You might want to consider ensuring that the symbol time is 
> sorted by address and then performing some kind of binary search on it.  (Or 
> do 
> you know that my_symbol_for_address will always be called with incrementally 
> increasing addresses, in which case you could just cache the last returned 
> value and start your search there).
> 
> > 3. Which macros should be used for the conditional compilation ? I've
> > used
> > #if defined(ARM_WINCE) || defined(SH4)
> > in my code. This happens to work for me because our build chain defines
> > ARM_WINCE, but I don't suppose this is right.
> 
> The correct way to handle this is to add a new function pointer field to the 
> bfd_coff_backend_data structure.  Arrange for this field to be initialized by 
> the various backends that need it (IA64, ARM, MIPS, SH) pointing at static 
> functions defined in the appropriate target specific source file (pe-arm.c 
> etc), and otherwise for it to be empty(*).  Then in 
> _bfd_XX_print_private_bfd_data_common test the field and call it if it is not 
> empty.
> 
> Cheers
>Nick
> 
> (*) Or maybe to point at a default pdata display function which does not try 
> to 
> provide any target specific interpretation.
Index: pe-arm-wince.c
===
--- pe-arm-wince.c	(revision 1151)
+++ pe-arm-wince.c	(working copy)
@@ -35,4 +35,179 @@
 
 #define LOCAL_LABEL_PREFIX "."
 
+#include "sysdep.h"
+#include "bfd.h"
+
+#undef bfd_pe_print_pdata
+#define	bfd_pe_print_pdata pe_print_compressed_pdata
+extern bfd_boolean pe_print_compressed_pdata (bfd * abfd, void * vfile);
+
 #include "pe-arm.c"
+
+static int symcount=0;
+static asymbol **
+slurp_symtab (bfd *abfd)
+{
+  asymbol **sy = NULL;
+  long storage;
+
+  if (!(bfd_get_file_flags (abfd) & HAS_SYMS))
+{
+  symcount = 0;
+  return NULL;
+}
+
+  storage = bfd_get_symtab_upper_bound (abfd);
+  if (storage < 0)
+return NULL;
+  if (storage)
+sy = bfd_malloc (storage);
+
+  symcount = bfd_canonicalize_symtab (abfd, sy);
+  if (symcount < 0)
+return NULL;
+  return sy;
+}
+
+static const char *
+my_symbol_for_address(bfd *abfd, bfd_vma func)
+{
+	static asymbol **syms = 0;
+	int i;
+
+	if (syms == 0)
+		syms = slurp_symtab (abfd);
+	for (i=0; isection->vma + syms[i]->value == func)
+			return syms[i]->name;
+	}
+	return NULL;
+}
+
+/* Copied from peXXigen.c , then modified for compressed pdata.
+
+   This really is architecture dependent.  On IA-64, a .pdata entry
+   consists of three dwords containing relative virtual addresses that
+   specify the start and end address of the code range the entry
+   covers and the address of the corresponding unwind info data. 
+
+   On ARM and SH-4, a compressed PDATA structure is used :
+   _IMAGE_CE_RUNTIME_FUNCTION_ENTRY, whereas MIPS is documented to use
+   _IMAGE_ALPHA_RUNTIME_FUNCTION_ENTRY.
+   See http://msdn2.microsoft.com/en-us/library/ms253988(VS.80).aspx .
+   */
+
+/* This is the version for "compressed" pdata.  */
+bfd_boolean
+pe_print_compressed_pdata (bfd * abfd, void * vfile)
+{
+# define PDATA_ROW_SIZE	(2 * 4)
+  FILE *file = (FILE *) vfile;
+  bfd_byte *data = 0;
+  asection *section = bfd_get_section_by_name (abfd, ".pdata");
+  bfd_size_type datasize = 0;
+  bfd_size_type i;
+  bfd_size_type start, stop;
+  int onaline = PDATA_ROW_SIZE;
+
+  if (section == NULL
+  || coff_section_data (abfd, section) == NULL
+  || pei_section_data (abfd, section) == NULL)
+return TRUE;
+
+  stop = pei_section_data (abfd, section)->virt_size;
+  if ((stop % onaline) != 0)
+fprintf (file,
+	 _("Warning, .pdata section size (%ld) is not a multiple of %d\n"),
+	 (long) stop, onaline);
+
+  fprintf (file,
+	   _("\nThe Function Table (interpreted .pdata section contents)\n"));
+
+  fprintf (file, _("\
+ vma:\t\tBeginProlog   Function FlagsException EH\n\
+ \t\tAddress  Length   Length   32b exc  Handler   Data\n"));
+
+  datasize = section->size;
+  if (datasize == 0)
+return TRUE;
+
+  if (! bfd_malloc_and_get_section (abfd, section, &data))
+{
+  if (data != NULL)
+	free (data);
+  return FALSE;
+}
+
+  start = 0;
+
+  for (i = start; i < stop; i += onaline)
+{
+  bfd_vma begin_addr;
+  bfd_vma other_data;
+  bfd_vma prolog_length, f

[Bug gold/5996] New: Testsuite failure: ./script_test_3: cannot execute binary file

2008-03-29 Thread schwab at suse dot de
The binary created by gold with script_test_3.t is rejected by the kernel.

-- 
   Summary: Testsuite failure: ./script_test_3: cannot execute
binary file
   Product: binutils
   Version: 2.19 (HEAD)
Status: NEW
  Severity: normal
  Priority: P2
 Component: gold
AssignedTo: ian at airs dot com
ReportedBy: schwab at suse dot de
CC: bug-binutils at gnu dot org
GCC target triplet: i386-suse-linux


http://sourceware.org/bugzilla/show_bug.cgi?id=5996

--- You are receiving this mail because: ---
You are on the CC list for the bug, or are watching someone who is.


___
bug-binutils mailing list
bug-binutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-binutils