This is the mail archive of the binutils@sourceware.org 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]

Failing PowerPC VLE tests


The failing VLE testcases annoyed me enough to fix them.  It turns out
that these failures
	FAIL: VLE multiple segments 1
	FAIL: VLE multiple segments 2
	FAIL: VLE multiple segments 3
are because ppc_elf_modify_segment_map isn't working.  The trouble
with using one of the packed bit section flags to mark VLE sections is
that these bits are not copied from input to output sections.
ppc_elf_modify_segment_map looks at output sections.  However, ELF
sh_flags are copied.  So use ELF sh_flags and get rid of the bfd
section flag entirely. 

These two failures
	FAIL: VLE relocations 2
	FAIL: VLE relocations 3
are due to the alignment of an empty .eh_frame affecting following
section addresses.  The cure is to use a custom linker script that
discards any unneeded sections.

bfd/
	* elf32-ppc.h (has_vle_insns, is_ppc_vle): Delete.
	(has_tls_reloc, has_tls_get_addr_call): Move back to..
	* elf32-ppc.c: ..here.
	(ppc_elf_section_flags, elf_backend_section_flags): Delete.
	(ppc_elf_modify_segment_map): Use ELF sh_flags to detect VLE sections.
opcodes/
	* ppc-dis.c: Don't include elf32-ppc.h, do include elf/ppc.h.
	(get_powerpc_dialect): Detect VLE sections from ELF sh_flags.
ld/testsuite/
	* ld-powerpc/vle.ld: New.
	* ld-powerpc/powerpc.exp (vle reloc tests): Link using vle.ld.

Index: bfd/elf32-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-ppc.c,v
retrieving revision 1.314
diff -u -p -r1.314 elf32-ppc.c
--- bfd/elf32-ppc.c	17 May 2012 02:43:34 -0000	1.314
+++ bfd/elf32-ppc.c	19 May 2012 06:16:32 -0000
@@ -2246,15 +2246,6 @@ ppc_elf_write_core_note (bfd *abfd, char
     }
 }
 
-static bfd_boolean
-ppc_elf_section_flags (flagword *flags ATTRIBUTE_UNUSED,
-		       const Elf_Internal_Shdr *hdr)
-{
-  if (hdr->sh_flags & SHF_PPC_VLE)
-    hdr->bfd_section->has_vle_insns = 1;
-  return TRUE;
-}
-
 static flagword
 ppc_elf_lookup_section_flags (char *flag_name) 
 {
@@ -2372,17 +2363,17 @@ ppc_elf_modify_segment_map (bfd *abfd,
       if (m->count == 0)
 	continue;
 
-      sect0_vle = is_ppc_vle (m->sections[0]);
+      sect0_vle = (elf_section_flags (m->sections[0]) & SHF_PPC_VLE) != 0;
       for (j = 1; j < m->count; ++j)
 	{
-	  if (is_ppc_vle (m->sections[j]) != sect0_vle)
+	  sectj_vle = (elf_section_flags (m->sections[j]) & SHF_PPC_VLE) != 0;
+
+	  if (sectj_vle != sect0_vle)
 	    break;
         }
       if (j >= m->count)
 	continue;
 
-      sectj_vle = is_ppc_vle (m->sections[j]);
-
       /* sections 0..j-1 stay in this (current) segment,
 	 the remainder are put in a new segment.
 	 The scan resumes with the new segment.  */
@@ -3120,6 +3111,15 @@ struct ppc_elf_link_hash_table
   struct sym_cache sym_cache;
 };
 
+/* Rename some of the generic section flags to better document how they
+   are used for ppc32.  The flags are only valid for ppc32 elf objects.  */
+
+/* Nonzero if this section has TLS related relocations.  */
+#define has_tls_reloc sec_flg0
+
+/* Nonzero if this section has a call to __tls_get_addr.  */
+#define has_tls_get_addr_call sec_flg1
+
 /* Get the PPC ELF linker hash table from a link_info structure.  */
 
 #define ppc_elf_hash_table(p) \
@@ -9710,7 +9710,6 @@ ppc_elf_finish_dynamic_sections (bfd *ou
 #define elf_backend_init_index_section		_bfd_elf_init_1_index_section
 #define elf_backend_post_process_headers	_bfd_elf_set_osabi
 #define elf_backend_lookup_section_flags_hook	ppc_elf_lookup_section_flags
-#define elf_backend_section_flags		ppc_elf_section_flags
 #define elf_backend_section_processing		ppc_elf_section_processing
 
 #include "elf32-target.h"
Index: bfd/elf32-ppc.h
===================================================================
RCS file: /cvs/src/src/bfd/elf32-ppc.h,v
retrieving revision 1.14
diff -u -p -r1.14 elf32-ppc.h
--- bfd/elf32-ppc.h	17 May 2012 02:24:50 -0000	1.14
+++ bfd/elf32-ppc.h	19 May 2012 06:16:32 -0000
@@ -26,26 +26,6 @@ enum ppc_elf_plt_type
   PLT_VXWORKS
 };
 
-/* Rename some of the generic section flags to better document how they
-   are used for ppc32.  These macros should be private to elf32-ppc.c,
-   but opcodes/ppc-dis.c needs is_ppc_vle.  The flags are only valid
-   for ppc32 elf objects.  */
-
-/* Nonzero if this section has TLS related relocations.  */
-#define has_tls_reloc sec_flg0
-
-/* Nonzero if this section has a call to __tls_get_addr.  */
-#define has_tls_get_addr_call sec_flg1
-
-/* Nonzero if this section has the VLE bit set.  */
-#define has_vle_insns sec_flg2
-
-#define is_ppc_vle(SEC) \
-  ((SEC)->owner != NULL						\
-   && bfd_get_flavour ((SEC)->owner) == bfd_target_elf_flavour	\
-   && elf_object_id ((SEC)->owner) == PPC32_ELF_DATA		\
-   && (SEC)->has_vle_insns)
-
 int ppc_elf_select_plt_layout (bfd *, struct bfd_link_info *,
 			       enum ppc_elf_plt_type, int);
 asection *ppc_elf_tls_setup (bfd *, struct bfd_link_info *, int);
Index: opcodes/ppc-dis.c
===================================================================
RCS file: /cvs/src/src/opcodes/ppc-dis.c,v
retrieving revision 1.57
diff -u -p -r1.57 ppc-dis.c
--- opcodes/ppc-dis.c	17 May 2012 15:13:25 -0000	1.57
+++ opcodes/ppc-dis.c	19 May 2012 06:17:01 -0000
@@ -24,7 +24,7 @@
 #include <stdio.h>
 #include "dis-asm.h"
 #include "elf-bfd.h"
-#include "elf32-ppc.h"
+#include "elf/ppc.h"
 #include "opintl.h"
 #include "opcode/ppc.h"
 
@@ -199,7 +199,10 @@ get_powerpc_dialect (struct disassemble_
 
   /* Disassemble according to the section headers flags for VLE-mode.  */
   if (dialect & PPC_OPCODE_VLE
-      && is_ppc_vle (info->section))
+      && info->section->owner != NULL
+      && bfd_get_flavour (info->section->owner) == bfd_target_elf_flavour
+      && elf_object_id (info->section->owner) == PPC32_ELF_DATA
+      && (elf_section_flags (info->section) & SHF_PPC_VLE) != 0)
     return dialect;
   else
     return dialect & ~ PPC_OPCODE_VLE;
Index: ld/testsuite/ld-powerpc/powerpc.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-powerpc/powerpc.exp,v
retrieving revision 1.39
diff -u -p -r1.39 powerpc.exp
--- ld/testsuite/ld-powerpc/powerpc.exp	14 May 2012 19:45:29 -0000	1.39
+++ ld/testsuite/ld-powerpc/powerpc.exp	19 May 2012 06:16:57 -0000
@@ -231,13 +231,13 @@ set ppceabitests {
     {"VLE multiple segments 5" "-T vle-multiseg-5.ld"
      "-mregnames -mvle" {vle-multiseg.s}
     {{readelf "-l" vle-multiseg-5.d}} "vle-multiseg-5"}
-    {"VLE relocations 1" ""
+    {"VLE relocations 1" "-T vle.ld"
      "-mvle" {vle-reloc-1.s vle-reloc-def-1.s}
     {{objdump "-Mvle -d" vle-reloc-1.d}} "vle-reloc-1"}
-    {"VLE relocations 2" ""
+    {"VLE relocations 2" "-T vle.ld"
      "-mvle" {vle-reloc-2.s vle-reloc-def-2.s}
     {{objdump "-Mvle -d" vle-reloc-2.d}} "vle-reloc-2"}
-    {"VLE relocations 3" ""
+    {"VLE relocations 3" "-T vle.ld"
      "-mvle" {vle-reloc-3.s vle-reloc-def-3.s}
     {{objdump "-Mvle -d" vle-reloc-3.d}} "vle-reloc-3"}
 }
Index: ld/testsuite/ld-powerpc/vle.ld
===================================================================
RCS file: ld/testsuite/ld-powerpc/vle.ld
diff -N ld/testsuite/ld-powerpc/vle.ld
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-powerpc/vle.ld	19 May 2012 06:41:13 -0000
@@ -0,0 +1,11 @@
+SECTIONS
+{
+  . = 0x01800000 + SIZEOF_HEADERS;
+  .text : { *(.text) }
+  .PPC.EMB.sdata0 : { *(.PPC.EMB.sdata0) }
+  .sdata2 : { PROVIDE (_SDA2_BASE_ = 32768); *(.sdata2) }
+  . = ALIGN (0x10000) + (. & (0x10000 - 1));
+  .data : { *(.data) }
+  .sdata : { PROVIDE (_SDA_BASE_ = 32768); *(.sdata) }
+  /DISCARD/ : { *(*) }
+}

-- 
Alan Modra
Australia Development Lab, IBM


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