This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

mips bfd: define NAME-like macro for elfxx-mips


The NAME macro doesn't work on elfxx-mips.c since it is not compiled
for either 32- or 64-bit ELF, but there are a number of places in this
file that reference a 32-bit function explicitly.  Without checking
whether those places are actually run only for 32-bit bfd operations,
I went ahead and introduced a NAME-equivalent macro that decides for
32- or 64- bit operations using the bfd, similarly to what was done
with the ELF_R_* macros.  I just named it differently from NAME,
because I didn't realize ELF_R_* had set a precedent of not renaming
the corresponding macro, but I myself find it confusing that the
prototype (so to speak) of the macro changes, so I kept the name
different.  Comments?  Ok to install?  Tested with a build for target
mips64-linux and a native irix6 build.

Index: bfd/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* elfxx-mips.c (MNAME): New macro.
	(_bfd_mips_elf_check_relocs): Use it.
	(_bfd_mips_elf_discard_info): Likewise.
	(_bfd_mips_elf_final_link): Likewise.

Index: bfd/elfxx-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-mips.c,v
retrieving revision 1.29
diff -u -p -r1.29 elfxx-mips.c
--- bfd/elfxx-mips.c 22 Oct 2002 22:17:11 -0000 1.29
+++ bfd/elfxx-mips.c 18 Nov 2002 20:48:31 -0000
@@ -475,6 +475,8 @@ static bfd *reldyn_sorting_bfd;
     : "/usr/lib/libc.so.1")
 
 #ifdef BFD64
+#define MNAME(bfd,pre,pos) \
+  (ABI_64_P (bfd) ? CONCAT4 (pre,64,_,pos) : CONCAT4 (pre,32,_,pos))
 #define ELF_R_SYM(bfd, i)					\
   (ABI_64_P (bfd) ? ELF64_R_SYM (i) : ELF32_R_SYM (i))
 #define ELF_R_TYPE(bfd, i)					\
@@ -482,6 +484,7 @@ static bfd *reldyn_sorting_bfd;
 #define ELF_R_INFO(bfd, s, t)					\
   (ABI_64_P (bfd) ? ELF64_R_INFO (s, t) : ELF32_R_INFO (s, t))
 #else
+#define MNAME(bfd,pre,pos) CONCAT4 (pre,32,_,pos)
 #define ELF_R_SYM(bfd, i)					\
   (ELF32_R_SYM (i))
 #define ELF_R_TYPE(bfd, i)					\
@@ -4128,7 +4131,7 @@ _bfd_mips_elf_check_relocs (abfd, info, 
 			      sizeof CALL_FP_STUB - 1) == 0)
 		continue;
 
-	      sec_relocs = (_bfd_elf32_link_read_relocs
+	      sec_relocs = (MNAME(abfd,_bfd_elf,link_read_relocs)
 			    (abfd, o, (PTR) NULL,
 			     (Elf_Internal_Rela *) NULL,
 			     info->keep_memory));
@@ -6481,9 +6484,10 @@ _bfd_mips_elf_discard_info (abfd, cookie
   if (! tdata)
     return false;
 
-  cookie->rels = _bfd_elf32_link_read_relocs (abfd, o, (PTR) NULL,
-					      (Elf_Internal_Rela *) NULL,
-					      info->keep_memory);
+  cookie->rels = (MNAME(abfd,_bfd_elf,link_read_relocs)
+		  (abfd, o, (PTR) NULL,
+		   (Elf_Internal_Rela *) NULL,
+		   info->keep_memory));
   if (!cookie->rels)
     {
       free (tdata);
@@ -6495,7 +6499,7 @@ _bfd_mips_elf_discard_info (abfd, cookie
 
   for (i = 0, skip = 0; i < o->_raw_size; i ++)
     {
-      if (_bfd_elf32_reloc_symbol_deleted_p (i * PDR_SIZE, cookie))
+      if (MNAME(abfd,_bfd_elf,reloc_symbol_deleted_p) (i * PDR_SIZE, cookie))
 	{
 	  tdata[i] = 1;
 	  skip ++;
@@ -7599,17 +7603,7 @@ _bfd_mips_elf_final_link (abfd, info)
     }
 
   /* Invoke the regular ELF backend linker to do all the work.  */
-  if (ABI_64_P (abfd))
-    {
-#ifdef BFD64
-      if (!bfd_elf64_bfd_final_link (abfd, info))
-	return false;
-#else
-      abort ();
-      return false;
-#endif /* BFD64 */
-    }
-  else if (!bfd_elf32_bfd_final_link (abfd, info))
+  if (!MNAME(abfd,bfd_elf,bfd_final_link) (abfd, info))
     return false;
 
   /* Now write out the computed sections.  */
-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                 aoliva@{redhat.com, gcc.gnu.org}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist                Professional serial bug killer

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]