public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Daniel Jacobowitz <drow@false.org>
To: Christophe LYON <christophe.lyon@st.com>, binutils@sourceware.org
Subject: Re: Fix Thumb-2 shared libraries
Date: Wed, 26 Aug 2009 03:11:00 -0000	[thread overview]
Message-ID: <20090825221433.GA8465@caradoc.them.org> (raw)
In-Reply-To: <20090825185158.GA2712@caradoc.them.org>

On Tue, Aug 25, 2009 at 02:51:58PM -0400, Daniel Jacobowitz wrote:
> Here's a patch I'm testing for this failure.

This time, the whole patch.

-- 
Daniel Jacobowitz
CodeSourcery

2009-08-25  Daniel Jacobowitz  <dan@codesourcery.com>

	bfd/
	* elf32-arm.c (elf32_arm_final_link_relocate): Set sym_flags
	for the mode of target PLT entries.
	(allocate_dynrelocs): Only adjust symbol type if setting its
	value.

2009-08-25  Daniel Jacobowitz  <dan@codesourcery.com>

	ld/testsuite/
	* ld-arm/farcall-mixed-lib.d: Update.

Index: ld/testsuite/ld-arm/farcall-mixed-lib.d
===================================================================
--- ld/testsuite/ld-arm/farcall-mixed-lib.d	(revision 259133)
+++ ld/testsuite/ld-arm/farcall-mixed-lib.d	(working copy)
@@ -39,9 +39,9 @@ Disassembly of section .text:
 
 .* <lib_func2>:
  .*:	f000 e80e 	blx	1000350 <__app_func_from_thumb>
- .*:	f000 e818 	blx	1000368 <__app_func_weak_from_thumb>
- .*:	f000 e810 	blx	100035c <__lib_func3_from_thumb>
- .*:	f000 e81a 	blx	1000374 <__lib_func4_from_thumb>
+ .*:	f000 e81a 	blx	100036c <__app_func_weak_from_thumb>
+ .*:	f000 e810 	blx	100035c <__lib_func3_veneer>
+ .*:	f000 e81c 	blx	1000378 <__lib_func4_from_thumb>
  .*:	4770      	bx	lr
  .*:	46c0      	nop			; \(mov r8, r8\)
  .*:	46c0      	nop			; \(mov r8, r8\)
@@ -56,20 +56,21 @@ Disassembly of section .text:
  .*:	e08ff00c 	add	pc, pc, ip
  .*:	feffff84 	.word	0xfeffff84
 
-.* <__lib_func3_from_thumb>:
- .*:	e59fc000 	ldr	ip, \[pc, #0\]	; 1000364 <__lib_func3_from_thumb\+0x8>
- .*:	e08ff00c 	add	pc, pc, ip
- .*:	feffff90 	.word	0xfeffff90
+.* <__lib_func3_veneer>:
+ .*:	e59fc004 	ldr	ip, \[pc, #4\]	; 1000368 <__lib_func3_veneer\+0xc>
+ .*:	e08fc00c 	add	ip, pc, ip
+ .*:	e12fff1c 	bx	ip
+ .*:	feffff91 	.word	0xfeffff91
 
 .* <__app_func_weak_from_thumb>:
- .*:	e59fc000 	ldr	ip, \[pc, #0\]	; 1000370 <__app_func_weak_from_thumb\+0x8>
+ .*:	e59fc000 	ldr	ip, \[pc, #0\]	; 1000374 <__app_func_weak_from_thumb\+0x8>
  .*:	e08ff00c 	add	pc, pc, ip
- .*:	feffff78 	.word	0xfeffff78
+ .*:	feffff74 	.word	0xfeffff74
 
 .* <__lib_func4_from_thumb>:
- .*:	e59fc000 	ldr	ip, \[pc, #0\]	; 100037c <__lib_func4_from_thumb\+0x8>
+ .*:	e59fc000 	ldr	ip, \[pc, #0\]	; 1000380 <__lib_func4_from_thumb\+0x8>
  .*:	e08ff00c 	add	pc, pc, ip
- .*:	feffff84 	.word	0xfeffff84
+ .*:	feffff80 	.word	0xfeffff80
 	...
 
 .* <lib_func3>:
Index: bfd/elf32-arm.c
===================================================================
--- bfd/elf32-arm.c	(revision 259133)
+++ bfd/elf32-arm.c	(working copy)
@@ -7330,6 +7330,9 @@ elf32_arm_final_link_relocate (reloc_how
 			   + splt->output_offset
 			   + h->plt.offset);
 		  *unresolved_reloc_p = FALSE;
+		  /* The PLT entry is in ARM mode, regardless of the
+		     target function.  */
+		  sym_flags = STT_FUNC;
 		}
 
 	      /* A branch to an undefined weak symbol is turned into a
@@ -7756,10 +7759,14 @@ elf32_arm_final_link_relocate (reloc_how
  		/* If the Thumb BLX instruction is available, convert the
 		   BL to a BLX instruction to call the ARM-mode PLT entry.  */
 		lower_insn = (lower_insn & ~0x1000) | 0x0800;
+		sym_flags = STT_FUNC;
  	      }
  	    else
- 	      /* Target the Thumb stub before the ARM PLT entry.  */
- 	      value -= PLT_THUMB_STUB_SIZE;
+	      {
+		/* Target the Thumb stub before the ARM PLT entry.  */
+		value -= PLT_THUMB_STUB_SIZE;
+		sym_flags = STT_ARM_TFUNC;
+	      }
 	    *unresolved_reloc_p = FALSE;
 	  }
 
@@ -11753,13 +11760,13 @@ allocate_dynrelocs (struct elf_link_hash
 	    {
 	      h->root.u.def.section = s;
 	      h->root.u.def.value = h->plt.offset;
-	    }
 
-	  /* Make sure the function is not marked as Thumb, in case
-	     it is the target of an ABS32 relocation, which will
-	     point to the PLT entry.  */
-	  if (ELF_ST_TYPE (h->type) == STT_ARM_TFUNC)
-	    h->type = ELF_ST_INFO (ELF_ST_BIND (h->type), STT_FUNC);
+	      /* Make sure the function is not marked as Thumb, in case
+		 it is the target of an ABS32 relocation, which will
+		 point to the PLT entry.  */
+	      if (ELF_ST_TYPE (h->type) == STT_ARM_TFUNC)
+		h->type = ELF_ST_INFO (ELF_ST_BIND (h->type), STT_FUNC);
+	    }
 
 	  /* Make room for this entry.  */
 	  s->size += htab->plt_entry_size;

  reply	other threads:[~2009-08-25 22:14 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-11 17:09 linker crash in arm stub generation Phil Blundell
2009-06-12 12:36 ` Nick Clifton
2009-06-12 13:19   ` Christophe LYON
2009-06-12 13:49     ` Nick Clifton
2009-06-12 14:06     ` Daniel Jacobowitz
2009-06-12 14:13       ` Christophe LYON
2009-06-15 14:22         ` Christophe LYON
2009-06-15 17:59           ` Daniel Jacobowitz
2009-06-17 15:44             ` Christophe LYON
2009-06-17 16:09               ` Phil Blundell
2009-06-17 18:10               ` Daniel Jacobowitz
2009-06-18 14:25                 ` Christophe LYON
2009-06-18 14:36                   ` Christophe LYON
2009-06-22  9:24                     ` Nick Clifton
2009-06-22 11:33                       ` Christophe LYON
2009-08-26  1:21                     ` Fix Thumb-2 shared libraries Daniel Jacobowitz
2009-08-26  3:11                       ` Daniel Jacobowitz [this message]
2009-09-09 18:36                         ` Daniel Jacobowitz
2009-09-14 12:30                           ` Daniel Jacobowitz
2009-08-26 10:39                       ` Christophe LYON
2009-08-26 15:00                         ` Daniel Jacobowitz
2009-08-26 17:24                           ` Christophe LYON

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090825221433.GA8465@caradoc.them.org \
    --to=drow@false.org \
    --cc=binutils@sourceware.org \
    --cc=christophe.lyon@st.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).