public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "H . J . Lu" <hjl@lucon.org>
To: Nick Clifton <nickc@cambridge.redhat.com>
Cc: binutils@sources.redhat.com, Ian Lance Taylor <ian@zembu.com>
Subject: Re: elf_link_hash_entry vs generic_link_hash_entry
Date: Thu, 23 Aug 2001 11:36:00 -0000	[thread overview]
Message-ID: <20010823113656.A17692@lucon.org> (raw)
In-Reply-To: <20010823092140.A15101@lucon.org>

On Thu, Aug 23, 2001 at 09:21:40AM -0700, H . J . Lu wrote:
> On Wed, Aug 22, 2001 at 08:41:11AM +0100, Nick Clifton wrote:
> > 
> >    3. Go back to the old situation where elf ports that do not provide
> >       their own relocation backends use the generic linker hash table
> >       entry structure, but add code to the other elf routines to
> >       detect this and fail before they try to access fields in the
> >       hash structure that are not there.
> > 
> 
> I'd like this one. How about we turn elf_hash_table into something
> specific to each backend? For those targets which don't use
> _bfd_elf_link_hash_table_create, it will return NULL or a fatal
> bfd error.
> 
> 

Here is a patch. Ian, as you mentioned, linking directly to S-records
no longer works. I got

/export/build/gnu/binutils/build-full-i686-linux/ld/ld-new  -o tmpdir/sr2.sr -T text 0x1000 --oformat srec tmpdir/sr1.o tmpdir/sr2.o
child killed: segmentation violation
FAIL: S-records
/export/build/gnu/binutils/build-full-i686-linux/ld/ld-new  -o tmpdir/sr2.sr -T text 0x1000 --oformat srec tmpdir/sr3.o
child killed: segmentation violation
FAIL: S-records with constructors

How should we fix it?

Thanks.


H.J.
----
2001-08-23  H.J. Lu  <hjl@gnu.org>

	* bfdlink.h (bfd_link_hash_table_type): New. The linker hash
	table type, bfd_link_generic_hash_table and
	bfd_link_elf_hash_table.
	(bfd_link_hash_table): Add a new field, type, for the linker
	hash table type.

2001-08-23  H.J. Lu  <hjl@gnu.org>

	* elf-bfd.h (elf_hash_table): Return NULL if the linker hash
	table is not an ELF linker hash table.

	* elf.c (_bfd_elf_link_hash_table_init): Set the linker hash
	table type to bfd_link_elf_hash_table.

	* elfxx-target.h (bfd_elfNN_bfd_link_hash_table_create): Revert
	the last change.

	* linker.c (_bfd_link_hash_table_init): Set the linker hash
	table type to bfd_link_generic_hash_table.

Index: bfd/elf-bfd.h
===================================================================
RCS file: /work/cvs/gnu/binutils/bfd/elf-bfd.h,v
retrieving revision 1.17
diff -u -p -r1.17 elf-bfd.h
--- bfd/elf-bfd.h	2001/08/23 17:02:19	1.17
+++ bfd/elf-bfd.h	2001/08/23 18:25:39
@@ -280,7 +280,9 @@ struct elf_link_hash_table
 
 /* Get the ELF linker hash table from a link_info structure.  */
 
-#define elf_hash_table(p) ((struct elf_link_hash_table *) ((p)->hash))
+#define elf_hash_table(p)						\
+  ((struct elf_link_hash_table *)					\
+     (((p)->hash->type == bfd_link_elf_hash_table) ? (p)->hash : NULL))
 \f
 /* Constant information held for an ELF backend.  */
 
Index: bfd/elf.c
===================================================================
RCS file: /work/cvs/gnu/binutils/bfd/elf.c,v
retrieving revision 1.62
diff -u -p -r1.62 elf.c
--- bfd/elf.c	2001/08/23 17:02:20	1.62
+++ bfd/elf.c	2001/08/23 18:25:40
@@ -1047,6 +1047,7 @@ _bfd_elf_link_hash_table_init (table, ab
 						struct bfd_hash_table *,
 						const char *));
 {
+  boolean ret;
   table->dynamic_sections_created = false;
   table->dynobj = NULL;
   /* The first dynamic symbol is a dummy.  */
@@ -1060,7 +1061,9 @@ _bfd_elf_link_hash_table_init (table, ab
   table->stab_info = NULL;
   table->merge_info = NULL;
   table->dynlocal = NULL;
-  return _bfd_link_hash_table_init (&table->root, abfd, newfunc);
+  ret = _bfd_link_hash_table_init (&table->root, abfd, newfunc);
+  table->root.type = bfd_link_elf_hash_table;
+  return ret;
 }
 
 /* Create an ELF linker hash table.  */
Index: bfd/elfxx-target.h
===================================================================
RCS file: /work/cvs/gnu/binutils/bfd/elfxx-target.h,v
retrieving revision 1.1.1.21
diff -u -p -r1.1.1.21 elfxx-target.h
--- bfd/elfxx-target.h	2001/08/23 16:39:09	1.1.1.21
+++ bfd/elfxx-target.h	2001/08/23 18:25:40
@@ -162,11 +162,16 @@ Foundation, Inc., 59 Temple Place - Suit
   _bfd_elf_canonicalize_dynamic_reloc
 #endif
 
+#ifdef elf_backend_relocate_section
 #ifndef bfd_elfNN_bfd_link_hash_table_create
 #define bfd_elfNN_bfd_link_hash_table_create _bfd_elf_link_hash_table_create
 #endif
-#ifndef elf_backend_relocate_section
+#else /* ! defined (elf_backend_relocate_section) */
 /* If no backend relocate_section routine, use the generic linker.  */
+#ifndef bfd_elfNN_bfd_link_hash_table_create
+#define bfd_elfNN_bfd_link_hash_table_create \
+  _bfd_generic_link_hash_table_create
+#endif
 #ifndef bfd_elfNN_bfd_link_add_symbols
 #define bfd_elfNN_bfd_link_add_symbols	_bfd_generic_link_add_symbols
 #endif
Index: bfd/linker.c
===================================================================
RCS file: /work/cvs/gnu/binutils/bfd/linker.c,v
retrieving revision 1.10
diff -u -p -r1.10 linker.c
--- bfd/linker.c	2001/08/17 17:56:20	1.10
+++ bfd/linker.c	2001/08/23 18:25:40
@@ -483,6 +483,7 @@ _bfd_link_hash_table_init (table, abfd, 
   table->creator = abfd->xvec;
   table->undefs = NULL;
   table->undefs_tail = NULL;
+  table->type = bfd_link_generic_hash_table;
   return bfd_hash_table_init (&table->table, newfunc);
 }
 
Index: include/bfdlink.h
===================================================================
RCS file: /work/cvs/gnu/binutils/include/bfdlink.h,v
retrieving revision 1.15
diff -u -p -r1.15 bfdlink.h
--- include/bfdlink.h	2001/08/23 17:02:23	1.15
+++ include/bfdlink.h	2001/08/23 18:25:42
@@ -42,6 +42,12 @@ enum bfd_link_discard
   discard_all		/* Discard all locals.  */
 };
 \f
+enum bfd_link_hash_table_type
+{
+  bfd_link_generic_hash_table,
+  bfd_link_elf_hash_table
+};
+
 /* These are the possible types of an entry in the BFD link hash
    table.  */
 
@@ -146,6 +152,8 @@ struct bfd_link_hash_table
   struct bfd_link_hash_entry *undefs;
   /* Entries are added to the tail of the undefs list.  */
   struct bfd_link_hash_entry *undefs_tail;
+  /* The type of the ink hash table.  */
+  enum bfd_link_hash_table_type type;
 };
 
 /* Look up an entry in a link hash table.  If FOLLOW is true, this

  reply	other threads:[~2001-08-23 11:36 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <si66bh2zdl.fsf@daffy.airs.com>
2001-08-22  0:44 ` Nick Clifton
2001-08-22  1:06   ` Thiemo Seufer
2001-08-22  7:02     ` Ian Lance Taylor
2001-08-23  9:22   ` H . J . Lu
2001-08-23 11:36     ` H . J . Lu [this message]
2001-08-23 12:10       ` H . J . Lu
2001-08-24  9:35         ` Nick Clifton
2001-08-24  9:54           ` H . J . Lu
2001-08-24 10:02           ` H . J . Lu
2001-08-24  9:18       ` Nick Clifton
2001-08-24  9:22         ` H . J . Lu
2001-08-28 15:53       ` Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010823113656.A17692@lucon.org \
    --to=hjl@lucon.org \
    --cc=binutils@sources.redhat.com \
    --cc=ian@zembu.com \
    --cc=nickc@cambridge.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).