This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: elf_link_hash_entry vs generic_link_hash_entry
On Thu, Aug 23, 2001 at 11:36:56AM -0700, H . J . Lu wrote:
> 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?
>
How about this patch?
H.J.
----
2001-08-23 H.J. Lu <hjl@gnu.org>
* elflink.h (elf_link_add_object_symbols): Don't merge section
nor add the file to the loaded list if the linker hash table
is not an an ELF linker hash table.
Index: elflink.h
===================================================================
RCS file: /work/cvs/gnu/binutils/bfd/elflink.h,v
retrieving revision 1.70
diff -u -p -r1.70 elflink.h
--- elflink.h 2001/08/23 17:02:20 1.70
+++ elflink.h 2001/08/23 19:07:05
@@ -1068,7 +1068,10 @@ elf_link_add_object_symbols (abfd, info)
Elf_External_Sym *esymend;
struct elf_backend_data *bed;
boolean dt_needed;
+ struct elf_link_hash_table *hash_table;
+ hash_table = elf_hash_table (info);
+
bed = get_elf_backend_data (abfd);
add_symbol_hook = bed->elf_add_symbol_hook;
collect = bed->collect;
@@ -2330,33 +2333,32 @@ elf_link_add_object_symbols (abfd, info)
}
}
- if (! info->relocateable && ! dynamic)
+ if (hash_table && ! info->relocateable && ! dynamic)
{
asection *s;
for (s = abfd->sections; s != NULL; s = s->next)
if ((s->flags & SEC_MERGE)
- && ! _bfd_merge_section (abfd,
- &elf_hash_table (info)->merge_info,
- s, &elf_section_data (s)->merge_info))
+ && ! _bfd_merge_section (abfd, &hash_table->merge_info, s,
+ &elf_section_data (s)->merge_info))
goto error_return;
}
+
+ if (hash_table)
+ {
+ /* We add this to the loaded list. */
+ struct elf_link_loaded_list *n, **pn;
- {
- /* We add this to the loaded list. */
- struct elf_link_loaded_list *n, **pn;
-
- n = ((struct elf_link_loaded_list *)
- bfd_alloc (abfd, sizeof (struct elf_link_loaded_list)));
- if (n == NULL)
- goto error_return;
- n->next = NULL;
- n->abfd = abfd;
- for (pn = &elf_hash_table (info)->loaded; *pn != NULL;
- pn = &(*pn)->next)
- ;
- *pn = n;
- }
+ n = ((struct elf_link_loaded_list *)
+ bfd_alloc (abfd, sizeof (struct elf_link_loaded_list)));
+ if (n == NULL)
+ goto error_return;
+ n->next = NULL;
+ n->abfd = abfd;
+ for (pn = &hash_table->loaded; *pn != NULL; pn = &(*pn)->next)
+ ;
+ *pn = n;
+ }
return true;