public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] VAX/ELF: Symbol visibility support
@ 2009-06-05  0:09 Maciej W. Rozycki
  2009-06-15 13:49 ` Nick Clifton
  0 siblings, 1 reply; 2+ messages in thread
From: Maciej W. Rozycki @ 2009-06-05  0:09 UTC (permalink / raw)
  To: binutils; +Cc: Jan-Benedict Glaw, linux-vax

Hello,

 This is a patch to add symbol visibility support to the VAX/ELF backend.  
Changes include attribute recognition in BFD so that GOT or PLT entries 
are not created as expected (unlimited PC-relative addressing is supported 
by VAX for all kinds of memory references, so there is no need for 
run-time relocation of local symbols) as well as a fix to GAS so as to 
permit indirect symbol references which inevitably will be generated for 
some hidden symbols by GCC.  Any errors resulting from the inability to 
route indirect references via the GOT -- which may happen for handcoded 
assembly only -- are already reported by the linker as they should be.

 Regression-tested successfully with the vax-linux target; running 
dynamically-linked `bash' on the target system (about the best native 
testing possible atm) revealed no problems either.

bfd/
2009-06-04  Maciej W. Rozycki  <macro@linux-mips.org>

	* elf32-vax.c (elf_vax_check_relocs): Handle the visibility 
	attribute.
	(elf_vax_relocate_section): Likewise.

gas/
2009-06-04  Maciej W. Rozycki  <macro@linux-mips.org>

	* config/tc-vax.c (md_estimate_size_before_relax): Accept
	indirect symbol references in the PIC mode and emit a
	PC-relative relocation instead of a GOT/PLT one.  Likewise
	for symbols known to be hidden at this point.

 OK to apply?

  Maciej

binutils-2.19.51-20090531-vax-elf-visibility.patch
diff -up --recursive --new-file binutils-2.19.51-20090531.macro/bfd/elf32-vax.c binutils-2.19.51-20090531/bfd/elf32-vax.c
--- binutils-2.19.51-20090531.macro/bfd/elf32-vax.c	2009-04-02 04:25:18.000000000 +0000
+++ binutils-2.19.51-20090531/bfd/elf32-vax.c	2009-06-01 23:23:15.000000000 +0000
@@ -605,6 +605,11 @@ elf_vax_check_relocs (bfd *abfd, struct 
 	      || h == elf_hash_table (info)->hplt)
 	    break;
 
+	  /* If this is a local symbol, we resolve it directly without
+	     creating a global offset table entry.  */
+	  if (h == NULL || ELF_ST_VISIBILITY (h->other) != STV_DEFAULT)
+	    break;
+
 	  /* This symbol requires a global offset table entry.  */
 
 	  if (dynobj == NULL)
@@ -677,7 +682,7 @@ elf_vax_check_relocs (bfd *abfd, struct 
 	  /* If this is a local symbol, we resolve it directly without
 	     creating a procedure linkage table entry.  */
 	  BFD_ASSERT (h != NULL);
-	  if (h->forced_local)
+	  if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT || h->forced_local)
 	    break;
 
 	  h->needs_plt = 1;
@@ -706,7 +711,9 @@ elf_vax_check_relocs (bfd *abfd, struct 
 		&& (!info->symbolic
 		    || !h->def_regular)))
 	    {
-	      if (h != NULL && !h->forced_local)
+	      if (h != NULL
+		  && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
+		  && !h->forced_local)
 		{
 		  /* Make sure a plt entry is created for this symbol if
 		     it turns out to be a function defined by a dynamic
@@ -718,14 +725,17 @@ elf_vax_check_relocs (bfd *abfd, struct 
 		}
 	      break;
 	    }
-	  if (h != NULL && h->forced_local)
+	  /* If this is a local symbol, we can resolve it directly.  */
+	  if (h != NULL
+	      && (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
+		  || h->forced_local))
 	    break;
 
 	  /* Fall through.  */
 	case R_VAX_8:
 	case R_VAX_16:
 	case R_VAX_32:
-	  if (h != NULL)
+	  if (h != NULL && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
 	    {
 	      /* Make sure a plt entry is created for this symbol if it
 		 turns out to be a function defined by a dynamic object.  */
@@ -1465,7 +1475,10 @@ elf_vax_relocate_section (bfd *output_bf
 	case R_VAX_GOT32:
 	  /* Relocation is to the address of the entry for this symbol
 	     in the global offset table.  */
-	  if (h == NULL || h->got.offset == (bfd_vma) -1 || h->forced_local)
+	  if (h == NULL
+	      || ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
+	      || h->got.offset == (bfd_vma) -1
+	      || h->forced_local)
 	    break;
 
 	  /* Relocation is the offset of the entry for this symbol in
@@ -1527,7 +1540,9 @@ elf_vax_relocate_section (bfd *output_bf
 
 	  /* Resolve a PLTxx reloc against a local symbol directly,
 	     without using the procedure linkage table.  */
-	  if (h == NULL || h->forced_local)
+	  if (h == NULL
+	      || ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
+	      || h->forced_local)
 	    break;
 
 	  if (h->plt.offset == (bfd_vma) -1
@@ -1581,7 +1596,9 @@ elf_vax_relocate_section (bfd *output_bf
 	case R_VAX_PC8:
 	case R_VAX_PC16:
 	case R_VAX_PC32:
-	  if (h == NULL || h->forced_local)
+	  if (h == NULL
+	      || ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
+	      || h->forced_local)
 	    break;
 	  /* Fall through.  */
 	case R_VAX_8:
diff -up --recursive --new-file binutils-2.19.51-20090531.macro/gas/config/tc-vax.c binutils-2.19.51-20090531/gas/config/tc-vax.c
--- binutils-2.19.51-20090531.macro/gas/config/tc-vax.c	2009-04-02 04:25:28.000000000 +0000
+++ binutils-2.19.51-20090531/gas/config/tc-vax.c	2009-06-01 23:23:15.000000000 +0000
@@ -396,23 +396,20 @@ md_estimate_size_before_relax (fragS *fr
 	          || S_IS_WEAK (fragP->fr_symbol)
 	          || S_IS_EXTERNAL (fragP->fr_symbol)))
 	    {
-	      if (p[0] & 0x10)
-		{
-		  if (flag_want_pic)
-		    as_fatal ("PIC reference to %s is indirect.\n",
-			      S_GET_NAME (fragP->fr_symbol));
-		}
+	      /* Indirect references cannot go through the GOT or PLT,
+	         let's hope they'll become local in the final link.  */
+	      if ((ELF_ST_VISIBILITY (S_GET_OTHER (fragP->fr_symbol))
+		   != STV_DEFAULT)
+		  || (p[0] & 0x10))
+		reloc_type = BFD_RELOC_32_PCREL;
+	      else if (((unsigned char *) fragP->fr_opcode)[0] == VAX_CALLS
+		       || ((unsigned char *) fragP->fr_opcode)[0] == VAX_CALLG
+		       || ((unsigned char *) fragP->fr_opcode)[0] == VAX_JSB
+		       || ((unsigned char *) fragP->fr_opcode)[0] == VAX_JMP
+		       || S_IS_FUNCTION (fragP->fr_symbol))
+		reloc_type = BFD_RELOC_32_PLT_PCREL;
 	      else
-		{
-		  if (((unsigned char *) fragP->fr_opcode)[0] == VAX_CALLS
-		      || ((unsigned char *) fragP->fr_opcode)[0] == VAX_CALLG
-		      || ((unsigned char *) fragP->fr_opcode)[0] == VAX_JSB
-		      || ((unsigned char *) fragP->fr_opcode)[0] == VAX_JMP
-		      || S_IS_FUNCTION (fragP->fr_symbol))
-		    reloc_type = BFD_RELOC_32_PLT_PCREL;
-		  else
-		    reloc_type = BFD_RELOC_32_GOT_PCREL;
-		}
+		reloc_type = BFD_RELOC_32_GOT_PCREL;
 	    }
 #endif
 	  switch (RELAX_STATE (fragP->fr_subtype))

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] VAX/ELF: Symbol visibility support
  2009-06-05  0:09 [PATCH] VAX/ELF: Symbol visibility support Maciej W. Rozycki
@ 2009-06-15 13:49 ` Nick Clifton
  0 siblings, 0 replies; 2+ messages in thread
From: Nick Clifton @ 2009-06-15 13:49 UTC (permalink / raw)
  To: Maciej W. Rozycki; +Cc: binutils, Jan-Benedict Glaw, linux-vax

Hi Maciej,

> bfd/
> 2009-06-04  Maciej W. Rozycki  <macro@linux-mips.org>
> 
> 	* elf32-vax.c (elf_vax_check_relocs): Handle the visibility 
> 	attribute.
> 	(elf_vax_relocate_section): Likewise.
> 
> gas/
> 2009-06-04  Maciej W. Rozycki  <macro@linux-mips.org>
> 
> 	* config/tc-vax.c (md_estimate_size_before_relax): Accept
> 	indirect symbol references in the PIC mode and emit a
> 	PC-relative relocation instead of a GOT/PLT one.  Likewise
> 	for symbols known to be hidden at this point.
> 
>  OK to apply?

Approved - please apply.

Cheers
   Nick


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-06-15 13:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-05  0:09 [PATCH] VAX/ELF: Symbol visibility support Maciej W. Rozycki
2009-06-15 13:49 ` Nick Clifton

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).