[PATCH] Add MIPS_ELF_TDATA to elf_object_id.
Richard Sandiford
rdsandiford@googlemail.com
Sat Jun 28 17:09:00 GMT 2008
More information about the Binutils mailing list
Sat Jun 28 17:09:00 GMT 2008
- Previous message (by thread): [PATCH, needs GWP] Add a BSF_SYNTHETIC flag
- Next message (by thread): [PATCH, needs GWP] Add an ELF rela_plts_and_copies_p parameter
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
This trivial patch extends the elf_object_id mechanism to MIPS.
It's then easier to tell whether a given BFD is MIPS or not.
Tested on mips64-linux-gnu and mips64el-linux-gnu. OK to install?
Richard
bfd/
* elf-bfd.h (MIPS_ELF_TDATA): New elf_object_id.
* elf32-mips.c (bfd_elf32_mkobject): Define.
* elf64-mips.c (bfd_elf64_mkobject): Likewise.
* elfn32-mips.c (bfd_elf32_mkobject): Likewise.
* elfxx-mips.h (_bfd_mips_elf_mkobject): Declare.
* elfxx-mips.c (is_mips_elf): New macro.
(_bfd_mips_elf_mkobject): New function.
(_bfd_mips_elf_final_link): Use is_mips_elf.
(_bfd_mips_elf_merge_private_bfd_data): Likewise.
Index: bfd/elf-bfd.h
===================================================================
--- bfd/elf-bfd.h 2008-06-28 17:09:01.000000000 +0100
+++ bfd/elf-bfd.h 2008-06-28 17:14:53.000000000 +0100
@@ -1408,6 +1408,7 @@ enum elf_object_id
ARM_ELF_TDATA,
HPPA_ELF_TDATA,
I386_ELF_TDATA,
+ MIPS_ELF_TDATA,
PPC32_ELF_TDATA,
PPC64_ELF_TDATA,
S390_ELF_TDATA,
Index: bfd/elf32-mips.c
===================================================================
--- bfd/elf32-mips.c 2008-06-28 17:14:36.000000000 +0100
+++ bfd/elf32-mips.c 2008-06-28 17:14:53.000000000 +0100
@@ -1629,6 +1629,7 @@ #define bfd_elf32_new_section_hook _bfd_
#define bfd_elf32_set_section_contents _bfd_mips_elf_set_section_contents
#define bfd_elf32_bfd_get_relocated_section_contents \
_bfd_elf_mips_get_relocated_section_contents
+#define bfd_elf32_mkobject _bfd_mips_elf_mkobject
#define bfd_elf32_bfd_link_hash_table_create \
_bfd_mips_elf_link_hash_table_create
#define bfd_elf32_bfd_final_link _bfd_mips_elf_final_link
Index: bfd/elf64-mips.c
===================================================================
--- bfd/elf64-mips.c 2008-06-28 17:14:36.000000000 +0100
+++ bfd/elf64-mips.c 2008-06-28 17:14:53.000000000 +0100
@@ -3210,6 +3210,7 @@ #define bfd_elf64_new_section_hook _bfd_
#define bfd_elf64_set_section_contents _bfd_mips_elf_set_section_contents
#define bfd_elf64_bfd_get_relocated_section_contents \
_bfd_elf_mips_get_relocated_section_contents
+#define bfd_elf64_mkobject _bfd_mips_elf_mkobject
#define bfd_elf64_bfd_link_hash_table_create \
_bfd_mips_elf_link_hash_table_create
#define bfd_elf64_bfd_final_link _bfd_mips_elf_final_link
Index: bfd/elfn32-mips.c
===================================================================
--- bfd/elfn32-mips.c 2008-06-28 17:14:36.000000000 +0100
+++ bfd/elfn32-mips.c 2008-06-28 17:14:53.000000000 +0100
@@ -2458,6 +2458,7 @@ #define bfd_elf32_new_section_hook _bfd_
#define bfd_elf32_set_section_contents _bfd_mips_elf_set_section_contents
#define bfd_elf32_bfd_get_relocated_section_contents \
_bfd_elf_mips_get_relocated_section_contents
+#define bfd_elf32_mkobject _bfd_mips_elf_mkobject
#define bfd_elf32_bfd_link_hash_table_create \
_bfd_mips_elf_link_hash_table_create
#define bfd_elf32_bfd_final_link _bfd_mips_elf_final_link
Index: bfd/elfxx-mips.h
===================================================================
--- bfd/elfxx-mips.h 2008-06-28 17:14:36.000000000 +0100
+++ bfd/elfxx-mips.h 2008-06-28 17:14:53.000000000 +0100
@@ -93,6 +93,8 @@
extern bfd_byte *_bfd_elf_mips_get_relocated_section_contents
(bfd *, struct bfd_link_info *, struct bfd_link_order *,
bfd_byte *, bfd_boolean, asymbol **);
+extern bfd_boolean _bfd_mips_elf_mkobject
+ (bfd *);
extern struct bfd_link_hash_table *_bfd_mips_elf_link_hash_table_create
(bfd *);
extern struct bfd_link_hash_table *_bfd_mips_vxworks_link_hash_table_create
Index: bfd/elfxx-mips.c
===================================================================
--- bfd/elfxx-mips.c 2008-06-28 17:14:50.000000000 +0100
+++ bfd/elfxx-mips.c 2008-06-28 17:14:53.000000000 +0100
@@ -243,6 +243,11 @@ struct _mips_elf_section_data
#define mips_elf_section_data(sec) \
((struct _mips_elf_section_data *) elf_section_data (sec))
+#define is_mips_elf(bfd) \
+ (bfd_get_flavour (bfd) == bfd_target_elf_flavour \
+ && elf_tdata (bfd) != NULL \
+ && elf_object_id (bfd) == MIPS_ELF_TDATA)
+
/* The ABI says that every symbol used by dynamic relocations must have
a global GOT entry. Among other things, this provides the dynamic
linker with a free, directly-indexed cache. The GOT can therefore
@@ -10598,6 +10603,15 @@ _bfd_mips_elf_set_section_contents (bfd
return NULL;
}
+/* Allocate ABFD's target-dependent data. */
+
+bfd_boolean
+_bfd_mips_elf_mkobject (bfd *abfd)
+{
+ return bfd_elf_allocate_object (abfd, sizeof (struct elf_obj_tdata),
+ MIPS_ELF_TDATA);
+}
+
/* Create a MIPS ELF linker hash table. */
struct bfd_link_hash_table *
@@ -10894,9 +10908,7 @@ _bfd_mips_elf_final_link (bfd *abfd, str
input_section = p->u.indirect.section;
input_bfd = input_section->owner;
- if (bfd_get_flavour (input_bfd) != bfd_target_elf_flavour
- || (get_elf_backend_data (input_bfd)
- ->elf_backend_ecoff_debug_swap) == NULL)
+ if (!is_mips_elf (input_bfd))
{
/* I don't know what a non MIPS ELF bfd would be
doing with a .mdebug section, but I don't really
@@ -11569,8 +11581,7 @@ _bfd_mips_elf_merge_private_bfd_data (bf
return FALSE;
}
- if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
- || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
+ if (!is_mips_elf (ibfd) || !is_mips_elf (obfd))
return TRUE;
if (strcmp (bfd_get_target (ibfd), bfd_get_target (obfd)) != 0)
- Previous message (by thread): [PATCH, needs GWP] Add a BSF_SYNTHETIC flag
- Next message (by thread): [PATCH, needs GWP] Add an ELF rela_plts_and_copies_p parameter
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Binutils mailing list