public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [arm] EABI annotation of thumb symbols.
@ 2004-11-02 14:22 Paul Brook
  2004-11-02 14:41 ` Richard Earnshaw
  2004-11-02 15:06 ` Ian Lance Taylor
  0 siblings, 2 replies; 15+ messages in thread
From: Paul Brook @ 2004-11-02 14:22 UTC (permalink / raw)
  To: binutils; +Cc: Richard Earnshaw

[-- Attachment #1: Type: text/plain, Size: 2986 bytes --]

The current Arm abi  identifies thumb function symbols by giving them type 
STT_ARM_TFUNC.

The Arm EABI specifies that thumb function symbols should be identified by 
setting the least significant bit of the address, and type STT_FUNC.

The patch below implements this. The main complication is that objdump -d 
breaks. I added a new bfd function to get the real address of a symbol. This 
seemed preferable to trying to mangle symbols while reading them in.

I'm open to alternative suggestions if people think this is the wrong way to 
implement this.

Paul

2004-10-29  Paul Brook  <paul@codesourcery.com>

gas/
 * config/tc-arm.c (arm_adjust_symtab): Set low bit on thumb function
 symbols for EABIv4 objects.
opcodes/
 * arm-dis.c (print_insn): Recognise thumb symbols by address.
binutils/
 * objdump.c: Use bfd_real_symbol_address instead of bfd_asymbol_value.
bfd/
 * elf32-arm.h (elf32_arm_relocate_section): Mask low bit on thumb
 function addresses.
 (elf32_arm_output_symbol_hook): Don't use STT_ARM_TFUMC in EABIv3
 objects.
 (elf32_arm_add_symbol_hook): New function.
 (elf_backend_add_symbol_hook): Define.
 (elf32_arm_real_symbol_address): New function.
 (bfd_elf32_real_symbol_address): Define.
 * syms.c (bfd_real_symbol_address): Add and document.
 (bfd_generic_real_symbol_address): New function.
 * targets.c (BFD_JUMP_TABLE_SYMBOLS): Add _real_symbol_address.
 (_real_symbol_address): New bfd target field.
 * libbfd-in.h (_bfd_nosymbols_real_symbol_address): Define.
 (bfd_generic_real_symbol_address): Add prototype.
 * coff-rs6000.c (rs6000coff_vec, pmac_xcoff_vec): Add
 bfd_generic_real_symbol_address.
 * coff64-rs6000.c (rs6000coff64_vec, aix5coff64_vec): Add
 bfd_generic_real_symbol_address.
 * aout-target.h (MY_real_symbol_address): Define.
 * aout-tic30.c (MY_real_symbol_address): Define.
 * binary.c (binary_real_symbol_address): Define.
 * coffcode.h (coff_real_symbol_address): Define.
 * elfxx-target.h (bfd_elfNN_real_symbol_address): Define.
 * i386msdos.c (msdos_real_symbol_address): Define.
 * ieee.c (ieee_real_symbol_address): Define.
 * ihex.c (ihex_real_symbol_address): Define.
 * libaout.h (aout_32_real_symbol_address): Define.
 * libbfd-in.h (_bfd_nosymbols_real_symbol_address): Define.
 * libecoff.h (_bfd_ecoff_real_symbol_address): Define.
 * mach-o.c (bfd_mach_o_real_symbol_address): Define.
 * mmo.c (mmo_real_symbol_address): Define.
 * nlm-target.h (nlm_real_symbol_address): Define.
 * oasys.c (oasys_real_symbol_address): Define.
 * pef.c (bfd_pef_real_symbol_address): Define.
 * ppcboot.c (ppcboot_real_symbol_address): Define.
 * som.c (som_real_symbol_address): Define.
 * srec.c (srec_real_symbol_address): Define.
 * tekhex.c (tekhex_real_symbol_address): Define.
 * versados.c (versados_real_symbol_address): Define.
 * vms.c (vms_real_symbol_address): Define.
 * xcoff-target.h (coff_real_symbol_address): Define.
 * xsym.c (bfd_sym_real_symbol_address): Define.
 * bfd-in2.h: Regenerate.
 * libbfd.h: Regenerate.

[-- Attachment #2: patch.thumb_eabi --]
[-- Type: text/x-diff, Size: 36080 bytes --]

? bfd/doc/bfd.info
? bfd/doc/bfdint.html
? gas/doc/as.info
? ld/ld.html
? ld/ldint.html
Index: bfd/aout-target.h
===================================================================
RCS file: /cvs/src/src/bfd/aout-target.h,v
retrieving revision 1.27
diff -u -p -r1.27 aout-target.h
--- bfd/aout-target.h	8 Oct 2004 14:53:54 -0000	1.27
+++ bfd/aout-target.h	29 Oct 2004 20:22:13 -0000
@@ -583,6 +583,10 @@ MY_bfd_final_link (abfd, info)
 #define MY_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
 #endif
 
+#ifndef MY_real_symbol_address
+#define MY_real_symbol_address bfd_generic_real_symbol_address
+#endif
+
 #ifndef MY_bfd_free_cached_info
 #define MY_bfd_free_cached_info NAME(aout,bfd_free_cached_info)
 #endif
Index: bfd/aout-tic30.c
===================================================================
RCS file: /cvs/src/src/bfd/aout-tic30.c,v
retrieving revision 1.27
diff -u -p -r1.27 aout-tic30.c
--- bfd/aout-tic30.c	8 Oct 2004 14:53:55 -0000	1.27
+++ bfd/aout-tic30.c	29 Oct 2004 20:22:13 -0000
@@ -1041,6 +1041,10 @@ tic30_aout_set_arch_mach (abfd, arch, ma
   ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
 #endif
 
+#ifndef MY_real_symbol_address
+#define MY_real_symbol_address bfd_generic_real_symbol_address
+#endif
+
 #ifndef MY_bfd_free_cached_info
 #define MY_bfd_free_cached_info NAME(aout,bfd_free_cached_info)
 #endif
Index: bfd/bfd-in2.h
===================================================================
RCS file: /cvs/src/src/bfd/bfd-in2.h,v
retrieving revision 1.305
diff -u -p -r1.305 bfd-in2.h
--- bfd/bfd-in2.h	16 Oct 2004 18:13:52 -0000	1.305
+++ bfd/bfd-in2.h	29 Oct 2004 20:22:15 -0000
@@ -3833,6 +3833,11 @@ bfd_boolean bfd_is_target_special_symbol
 #define bfd_is_target_special_symbol(abfd, sym) \
   BFD_SEND (abfd, _bfd_is_target_special_symbol, (abfd, sym))
 
+bfd_vma bfd_real_symbol_address (bfd *abfd, asymbol *sym);
+
+#define bfd_real_symbol_address(sym) \
+  BFD_SEND (sym->the_bfd, _real_symbol_address, (sym))
+
 #define bfd_canonicalize_symtab(abfd, location) \
   BFD_SEND (abfd, _bfd_canonicalize_symtab, (abfd, location))
 
@@ -4452,6 +4457,7 @@ typedef struct bfd_target
   NAME##_get_symbol_info, \
   NAME##_bfd_is_local_label_name, \
   NAME##_bfd_is_target_special_symbol, \
+  NAME##_real_symbol_address, \
   NAME##_get_lineno, \
   NAME##_find_nearest_line, \
   NAME##_bfd_make_debug_symbol, \
@@ -4471,6 +4477,7 @@ typedef struct bfd_target
 #define bfd_get_symbol_info(b,p,e) BFD_SEND (b, _bfd_get_symbol_info, (b,p,e))
   bfd_boolean (*_bfd_is_local_label_name) (bfd *, const char *);
   bfd_boolean (*_bfd_is_target_special_symbol) (bfd *, asymbol *);
+  bfd_vma     (*_real_symbol_address) (asymbol *);
   alent *     (*_get_lineno) (bfd *, struct bfd_symbol *);
   bfd_boolean (*_bfd_find_nearest_line)
     (bfd *, struct bfd_section *, struct bfd_symbol **, bfd_vma,
Index: bfd/binary.c
===================================================================
RCS file: /cvs/src/src/bfd/binary.c,v
retrieving revision 1.24
diff -u -p -r1.24 binary.c
--- bfd/binary.c	8 Oct 2004 14:53:56 -0000	1.24
+++ bfd/binary.c	29 Oct 2004 20:22:15 -0000
@@ -235,6 +235,7 @@ binary_get_symbol_info (ignore_abfd, sym
 }
 
 #define binary_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
+#define binary_real_symbol_address bfd_generic_real_symbol_address
 #define binary_bfd_is_local_label_name bfd_generic_is_local_label_name
 #define binary_get_lineno _bfd_nosymbols_get_lineno
 #define binary_find_nearest_line _bfd_nosymbols_find_nearest_line
Index: bfd/coff-rs6000.c
===================================================================
RCS file: /cvs/src/src/bfd/coff-rs6000.c,v
retrieving revision 1.66
diff -u -p -r1.66 coff-rs6000.c
--- bfd/coff-rs6000.c	21 Oct 2004 15:28:16 -0000	1.66
+++ bfd/coff-rs6000.c	29 Oct 2004 20:22:16 -0000
@@ -4171,6 +4171,7 @@ const bfd_target rs6000coff_vec =
     coff_get_symbol_info,
     _bfd_xcoff_is_local_label_name,
     coff_bfd_is_target_special_symbol,
+    bfd_generic_real_symbol_address,
     coff_get_lineno,
     coff_find_nearest_line,
     coff_bfd_make_debug_symbol,
@@ -4418,6 +4419,7 @@ const bfd_target pmac_xcoff_vec =
     coff_get_symbol_info,
     _bfd_xcoff_is_local_label_name,
     coff_bfd_is_target_special_symbol,
+    bfd_generic_real_symbol_address,
     coff_get_lineno,
     coff_find_nearest_line,
     coff_bfd_make_debug_symbol,
Index: bfd/coff64-rs6000.c
===================================================================
RCS file: /cvs/src/src/bfd/coff64-rs6000.c,v
retrieving revision 1.57
diff -u -p -r1.57 coff64-rs6000.c
--- bfd/coff64-rs6000.c	21 Oct 2004 15:28:19 -0000	1.57
+++ bfd/coff64-rs6000.c	29 Oct 2004 20:22:16 -0000
@@ -2712,6 +2712,7 @@ const bfd_target rs6000coff64_vec =
     coff_get_symbol_info,
     _bfd_xcoff_is_local_label_name,
     coff_bfd_is_target_special_symbol,
+    bfd_generic_real_symbol_address,
     coff_get_lineno,
     coff_find_nearest_line,
     coff_bfd_make_debug_symbol,
@@ -2960,6 +2961,7 @@ const bfd_target aix5coff64_vec =
     coff_get_symbol_info,
     _bfd_xcoff_is_local_label_name,
     coff_bfd_is_target_special_symbol,
+    bfd_generic_real_symbol_address,
     coff_get_lineno,
     coff_find_nearest_line,
     coff_bfd_make_debug_symbol,
Index: bfd/coffcode.h
===================================================================
RCS file: /cvs/src/src/bfd/coffcode.h,v
retrieving revision 1.113
diff -u -p -r1.113 coffcode.h
--- bfd/coffcode.h	13 Oct 2004 18:14:40 -0000	1.113
+++ bfd/coffcode.h	29 Oct 2004 20:22:17 -0000
@@ -5551,6 +5551,10 @@ static const bfd_coff_backend_data ticof
 #define coff_bfd_is_target_special_symbol   ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
 #endif
 
+#ifndef coff_real_symbol_address
+#define coff_real_symbol_address            bfd_generic_real_symbol_address
+#endif
+
 #ifndef coff_read_minisymbols
 #define coff_read_minisymbols		    _bfd_generic_read_minisymbols
 #endif
Index: bfd/elf32-arm.h
===================================================================
RCS file: /cvs/src/src/bfd/elf32-arm.h,v
retrieving revision 1.155
diff -u -p -r1.155 elf32-arm.h
--- bfd/elf32-arm.h	27 Oct 2004 20:48:21 -0000	1.155
+++ bfd/elf32-arm.h	29 Oct 2004 20:22:19 -0000
@@ -2103,6 +2103,7 @@ elf32_arm_relocate_section (bfd *       
       bfd_vma                      relocation;
       bfd_reloc_status_type        r;
       arelent                      bfd_reloc;
+      int			   s_type;
 
       r_symndx = ELF32_R_SYM (rel->r_info);
       r_type   = ELF32_R_TYPE (rel->r_info);
@@ -2270,11 +2271,19 @@ elf32_arm_relocate_section (bfd *       
 	    name = bfd_section_name (input_bfd, sec);
 	}
 
+      s_type = h ? ELF_ST_TYPE (h->type) : ELF_ST_TYPE (sym->st_info);
+      /* The low bit of function addresses is used to indicate a thumb
+	 function, and is not part of the relocated address.  */
+      if (sym && s_type == STT_FUNC && (relocation & 1))
+	{
+	  s_type = STT_ARM_TFUNC;
+	  relocation = relocation &~ (bfd_vma) 1;
+	}
+
       r = elf32_arm_final_link_relocate (howto, input_bfd, output_bfd,
 					 input_section, contents, rel,
 					 relocation, info, sec, name,
-					 (h ? ELF_ST_TYPE (h->type) :
-					  ELF_ST_TYPE (sym->st_info)), h);
+					 s_type, h);
 
       if (r != bfd_reloc_ok)
 	{
@@ -3211,6 +3220,14 @@ elf32_arm_is_target_special_symbol (bfd 
   return is_arm_mapping_symbol_name (sym->name);
 }
 
+/* Make sure the low bit is cleared for thumb symbols.  */
+
+static bfd_vma
+elf32_arm_real_symbol_address (asymbol * sym)
+{
+  return bfd_generic_real_symbol_address (sym) &~ (bfd_vma) 1;
+}
+
 /* This is a copy of elf_find_function() from elf.c except that
    ARM mapping symbols are ignored when looking for function names
    and STT_ARM_TFUNC is considered to a function type.  */
@@ -4381,6 +4398,15 @@ elf32_arm_output_symbol_hook (struct bfd
   elf32_arm_section_map *map;
   struct elf32_arm_link_hash_table *globals;
 
+  if (ELF_ST_TYPE (elfsym->st_info) == STT_ARM_TFUNC
+      && EF_ARM_EABI_VERSION (elf_elfheader (input_sec->owner)->e_flags)
+	== EF_ARM_EABI_VER3)
+    {
+      /* STT_ARM_TFUNC is only for internal use.  */
+      elfsym->st_info = ELF_ST_INFO (ELF_ST_BIND (elfsym->st_info),
+				     STT_FUNC);
+    }
+
   /* Only do this on final link.  */
   if (info->relocatable)
     return TRUE;
@@ -4504,6 +4530,33 @@ elf32_arm_write_section (bfd *output_bfd
   return FALSE;
 }
 
+
+/* A thumb function can be annotated by either type STT_ARM_TFUNC, or
+   by setting the low bit of the value.  This function sets type to
+   STT_ARM_TFUNC in the latter case, so they can be identified by
+   bfd_elf32_arm_process_before_allocation.  This will be undone in
+   elf32_arm_output_symbol_hook if neccessary.  */
+
+static bfd_boolean
+elf32_arm_add_symbol_hook (bfd *abfd ATTRIBUTE_UNUSED,
+			   struct bfd_link_info *info ATTRIBUTE_UNUSED,
+			   Elf_Internal_Sym *sym,
+			   const char **name ATTRIBUTE_UNUSED,
+			   flagword *flags ATTRIBUTE_UNUSED,
+			   asection **sec ATTRIBUTE_UNUSED,
+			   bfd_vma *value ATTRIBUTE_UNUSED)
+{
+  switch (ELF_ST_TYPE (sym->st_info))
+    {
+    case STT_FUNC:
+      if (sym->st_value & 1)
+	sym->st_info = ELF_ST_INFO (ELF_ST_BIND (sym->st_info),
+				    STT_ARM_TFUNC);
+      break;
+    }
+  return TRUE;
+}
+
 #define ELF_ARCH			bfd_arch_arm
 #define ELF_MACHINE_CODE		EM_ARM
 #ifdef __QNXTARGET__
@@ -4521,6 +4574,7 @@ elf32_arm_write_section (bfd *output_bfd
 #define bfd_elf32_find_nearest_line	        elf32_arm_find_nearest_line
 #define bfd_elf32_new_section_hook		elf32_arm_new_section_hook
 #define bfd_elf32_bfd_is_target_special_symbol	elf32_arm_is_target_special_symbol
+#define bfd_elf32_real_symbol_address		elf32_arm_real_symbol_address
 
 #define elf_backend_get_symbol_type             elf32_arm_get_symbol_type
 #define elf_backend_gc_mark_hook                elf32_arm_gc_mark_hook
@@ -4542,6 +4596,7 @@ elf32_arm_write_section (bfd *output_bfd
 #define elf_backend_section_from_shdr  		elf32_arm_section_from_shdr
 #define elf_backend_final_write_processing      elf32_arm_final_write_processing
 #define elf_backend_copy_indirect_symbol        elf32_arm_copy_indirect_symbol
+#define elf_backend_add_symbol_hook		elf32_arm_add_symbol_hook
 
 #define elf_backend_can_refcount    1
 #define elf_backend_can_gc_sections 1
Index: bfd/elfxx-target.h
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-target.h,v
retrieving revision 1.73
diff -u -p -r1.73 elfxx-target.h
--- bfd/elfxx-target.h	8 Oct 2004 14:53:59 -0000	1.73
+++ bfd/elfxx-target.h	29 Oct 2004 20:22:19 -0000
@@ -192,6 +192,9 @@
 #define bfd_elfNN_bfd_is_target_special_symbol \
   ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
 #endif
+#ifndef bfd_elfNN_real_symbol_address
+#define bfd_elfNN_real_symbol_address bfd_generic_real_symbol_address
+#endif
 
 #ifndef bfd_elfNN_get_dynamic_reloc_upper_bound
 #define bfd_elfNN_get_dynamic_reloc_upper_bound \
Index: bfd/i386msdos.c
===================================================================
RCS file: /cvs/src/src/bfd/i386msdos.c,v
retrieving revision 1.18
diff -u -p -r1.18 i386msdos.c
--- bfd/i386msdos.c	8 Oct 2004 14:54:00 -0000	1.18
+++ bfd/i386msdos.c	29 Oct 2004 20:22:19 -0000
@@ -194,6 +194,7 @@ msdos_set_section_contents (abfd, sectio
 #define msdos_find_nearest_line _bfd_nosymbols_find_nearest_line
 #define msdos_get_lineno _bfd_nosymbols_get_lineno
 #define msdos_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
+#define msdos_real_symbol_address bfd_generic_real_symbol_address
 #define msdos_bfd_is_local_label_name _bfd_nosymbols_bfd_is_local_label_name
 #define msdos_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
 #define msdos_read_minisymbols _bfd_nosymbols_read_minisymbols
Index: bfd/ieee.c
===================================================================
RCS file: /cvs/src/src/bfd/ieee.c,v
retrieving revision 1.41
diff -u -p -r1.41 ieee.c
--- bfd/ieee.c	8 Oct 2004 14:54:00 -0000	1.41
+++ bfd/ieee.c	29 Oct 2004 20:22:20 -0000
@@ -4020,6 +4020,7 @@ ieee_bfd_debug_info_accumulate (abfd, se
 
 #define ieee_bfd_is_target_special_symbol  \
   ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
+#define ieee_real_symbol_address bfd_generic_real_symbol_address
 #define ieee_bfd_is_local_label_name bfd_generic_is_local_label_name
 #define ieee_get_lineno _bfd_nosymbols_get_lineno
 #define ieee_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
Index: bfd/ihex.c
===================================================================
RCS file: /cvs/src/src/bfd/ihex.c,v
retrieving revision 1.26
diff -u -p -r1.26 ihex.c
--- bfd/ihex.c	8 Oct 2004 14:54:00 -0000	1.26
+++ bfd/ihex.c	29 Oct 2004 20:22:20 -0000
@@ -969,6 +969,7 @@ ihex_sizeof_headers (abfd, exec)
 #define ihex_print_symbol _bfd_nosymbols_print_symbol
 #define ihex_get_symbol_info _bfd_nosymbols_get_symbol_info
 #define ihex_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
+#define ihex_real_symbol_address bfd_generic_real_symbol_address
 #define ihex_bfd_is_local_label_name _bfd_nosymbols_bfd_is_local_label_name
 #define ihex_get_lineno _bfd_nosymbols_get_lineno
 #define ihex_find_nearest_line _bfd_nosymbols_find_nearest_line
Index: bfd/libaout.h
===================================================================
RCS file: /cvs/src/src/bfd/libaout.h,v
retrieving revision 1.18
diff -u -p -r1.18 libaout.h
--- bfd/libaout.h	8 Oct 2004 14:54:00 -0000	1.18
+++ bfd/libaout.h	29 Oct 2004 20:22:20 -0000
@@ -611,6 +611,10 @@ extern bfd_boolean NAME(aout,bfd_free_ca
   ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
 #endif
 
+#ifndef aout_32_real_symbol_address
+#define aout_32_real_symbol_address bfd_generic_real_symbol_address
+#endif
+
 #ifndef WRITE_HEADERS
 #define WRITE_HEADERS(abfd, execp)					      \
       {									      \
Index: bfd/libbfd-in.h
===================================================================
RCS file: /cvs/src/src/bfd/libbfd-in.h,v
retrieving revision 1.44
diff -u -p -r1.44 libbfd-in.h
--- bfd/libbfd-in.h	10 Oct 2004 13:58:04 -0000	1.44
+++ bfd/libbfd-in.h	29 Oct 2004 20:22:20 -0000
@@ -301,6 +301,7 @@ extern bfd_boolean _bfd_archive_coff_con
   ((bfd_boolean (*) (bfd *, const char *)) bfd_false)
 #define _bfd_nosymbols_bfd_is_target_special_symbol \
   ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
+#define _bfd_nosymbols_real_symbol_address bfd_generic_real_symbol_address
 #define _bfd_nosymbols_get_lineno \
   ((alent *(*) (bfd *, asymbol *)) bfd_nullvoidptr)
 #define _bfd_nosymbols_find_nearest_line \
@@ -394,6 +395,10 @@ extern bfd_boolean _bfd_generic_set_sect
 #define _bfd_nodynamic_canonicalize_dynamic_reloc \
   ((long (*) (bfd *, arelent **, asymbol **)) _bfd_n1)
 \f
+/* Generic routine to get the address of a sybol.  */
+extern bfd_vma bfd_generic_real_symbol_address
+  (asymbol *);
+
 /* Generic routine to determine of the given symbol is a local
    label.  */
 extern bfd_boolean bfd_generic_is_local_label_name
Index: bfd/libbfd.h
===================================================================
RCS file: /cvs/src/src/bfd/libbfd.h,v
retrieving revision 1.129
diff -u -p -r1.129 libbfd.h
--- bfd/libbfd.h	10 Oct 2004 13:58:04 -0000	1.129
+++ bfd/libbfd.h	29 Oct 2004 20:22:20 -0000
@@ -306,6 +306,7 @@ extern bfd_boolean _bfd_archive_coff_con
   ((bfd_boolean (*) (bfd *, const char *)) bfd_false)
 #define _bfd_nosymbols_bfd_is_target_special_symbol \
   ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
+#define _bfd_nosymbols_real_symbol_address bfd_generic_real_symbol_address
 #define _bfd_nosymbols_get_lineno \
   ((alent *(*) (bfd *, asymbol *)) bfd_nullvoidptr)
 #define _bfd_nosymbols_find_nearest_line \
@@ -399,6 +400,10 @@ extern bfd_boolean _bfd_generic_set_sect
 #define _bfd_nodynamic_canonicalize_dynamic_reloc \
   ((long (*) (bfd *, arelent **, asymbol **)) _bfd_n1)
 \f
+/* Generic routine to get the address of a sybol.  */
+extern bfd_vma bfd_generic_real_symbol_address
+  (asymbol *);
+
 /* Generic routine to determine of the given symbol is a local
    label.  */
 extern bfd_boolean bfd_generic_is_local_label_name
Index: bfd/libecoff.h
===================================================================
RCS file: /cvs/src/src/bfd/libecoff.h,v
retrieving revision 1.17
diff -u -p -r1.17 libecoff.h
--- bfd/libecoff.h	8 Oct 2004 14:54:01 -0000	1.17
+++ bfd/libecoff.h	29 Oct 2004 20:22:20 -0000
@@ -274,6 +274,7 @@ extern bfd_boolean _bfd_ecoff_write_arma
 #define _bfd_ecoff_update_armap_timestamp bfd_true
 #define _bfd_ecoff_bfd_is_target_special_symbol  \
   ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
+#define _bfd_ecoff_real_symbol_address bfd_generic_real_symbol_address
 
 extern long _bfd_ecoff_get_symtab_upper_bound PARAMS ((bfd *abfd));
 extern long _bfd_ecoff_canonicalize_symtab PARAMS ((bfd *abfd, asymbol **alocation));
Index: bfd/mach-o.c
===================================================================
RCS file: /cvs/src/src/bfd/mach-o.c,v
retrieving revision 1.12
diff -u -p -r1.12 mach-o.c
--- bfd/mach-o.c	8 Oct 2004 14:54:01 -0000	1.12
+++ bfd/mach-o.c	29 Oct 2004 20:22:21 -0000
@@ -45,6 +45,7 @@
 #define bfd_mach_o_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
 #define bfd_mach_o_bfd_is_local_label_name _bfd_nosymbols_bfd_is_local_label_name
 #define bfd_mach_o_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
+#define bfd_mach_o_real_symbol_address bfd_generic_real_symbol_address
 #define bfd_mach_o_bfd_is_local_label_name _bfd_nosymbols_bfd_is_local_label_name
 #define bfd_mach_o_get_lineno _bfd_nosymbols_get_lineno
 #define bfd_mach_o_find_nearest_line _bfd_nosymbols_find_nearest_line
Index: bfd/mmo.c
===================================================================
RCS file: /cvs/src/src/bfd/mmo.c,v
retrieving revision 1.24
diff -u -p -r1.24 mmo.c
--- bfd/mmo.c	24 Oct 2004 22:50:43 -0000	1.24
+++ bfd/mmo.c	29 Oct 2004 20:22:22 -0000
@@ -3195,6 +3195,7 @@ mmo_canonicalize_reloc (bfd *abfd ATTRIB
 #define mmo_bfd_is_local_label_name bfd_generic_is_local_label_name
 #define mmo_bfd_is_target_special_symbol  \
   ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
+#define mmo_real_symbol_address bfd_generic_real_symbol_address
 
 /* Is this one really used or defined by anyone?  */
 #define mmo_get_lineno _bfd_nosymbols_get_lineno
Index: bfd/nlm-target.h
===================================================================
RCS file: /cvs/src/src/bfd/nlm-target.h,v
retrieving revision 1.13
diff -u -p -r1.13 nlm-target.h
--- bfd/nlm-target.h	8 Oct 2004 14:54:01 -0000	1.13
+++ bfd/nlm-target.h	29 Oct 2004 20:22:22 -0000
@@ -28,6 +28,7 @@ Foundation, Inc., 59 Temple Place - Suit
 #define nlm_bfd_is_local_label_name bfd_generic_is_local_label_name
 #define nlm_bfd_is_target_special_symbol  \
   ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
+#define nlm_real_symbol_address bfd_generic_real_symbol_address
 #define nlm_get_lineno _bfd_nosymbols_get_lineno
 #define nlm_find_nearest_line _bfd_nosymbols_find_nearest_line
 #define nlm_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
Index: bfd/oasys.c
===================================================================
RCS file: /cvs/src/src/bfd/oasys.c,v
retrieving revision 1.26
diff -u -p -r1.26 oasys.c
--- bfd/oasys.c	8 Oct 2004 14:54:01 -0000	1.26
+++ bfd/oasys.c	29 Oct 2004 20:22:22 -0000
@@ -1490,6 +1490,7 @@ oasys_sizeof_headers (abfd, exec)
 
 #define oasys_bfd_is_local_label_name bfd_generic_is_local_label_name
 #define oasys_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
+#define oasys_real_symbol_address bfd_generic_real_symbol_address
 #define oasys_get_lineno _bfd_nosymbols_get_lineno
 #define oasys_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
 #define oasys_read_minisymbols _bfd_generic_read_minisymbols
Index: bfd/pef.c
===================================================================
RCS file: /cvs/src/src/bfd/pef.c,v
retrieving revision 1.10
diff -u -p -r1.10 pef.c
--- bfd/pef.c	8 Oct 2004 14:54:01 -0000	1.10
+++ bfd/pef.c	29 Oct 2004 20:22:22 -0000
@@ -38,6 +38,7 @@
 #define bfd_pef_new_section_hook                    _bfd_generic_new_section_hook
 #define bfd_pef_bfd_is_local_label_name             bfd_generic_is_local_label_name
 #define bfd_pef_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
+#define bfd_pef_real_symbol_address                 bfd_generic_real_symbol_address
 #define bfd_pef_get_lineno                          _bfd_nosymbols_get_lineno
 #define bfd_pef_find_nearest_line                   _bfd_nosymbols_find_nearest_line
 #define bfd_pef_bfd_make_debug_symbol               _bfd_nosymbols_bfd_make_debug_symbol
Index: bfd/ppcboot.c
===================================================================
RCS file: /cvs/src/src/bfd/ppcboot.c,v
retrieving revision 1.21
diff -u -p -r1.21 ppcboot.c
--- bfd/ppcboot.c	8 Oct 2004 14:54:01 -0000	1.21
+++ bfd/ppcboot.c	29 Oct 2004 20:22:22 -0000
@@ -347,6 +347,7 @@ ppcboot_get_symbol_info (ignore_abfd, sy
 
 #define ppcboot_bfd_is_target_special_symbol \
   ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
+#define ppcboot_real_symbol_address bfd_generic_real_symbol_address
 #define ppcboot_bfd_is_local_label_name bfd_generic_is_local_label_name
 #define ppcboot_get_lineno _bfd_nosymbols_get_lineno
 #define ppcboot_find_nearest_line _bfd_nosymbols_find_nearest_line
Index: bfd/som.c
===================================================================
RCS file: /cvs/src/src/bfd/som.c,v
retrieving revision 1.48
diff -u -p -r1.48 som.c
--- bfd/som.c	9 Oct 2004 02:51:31 -0000	1.48
+++ bfd/som.c	29 Oct 2004 20:22:24 -0000
@@ -6404,6 +6404,7 @@ som_bfd_link_split_section (abfd, sec)
 
 #define som_bfd_is_target_special_symbol \
   ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
+#define som_real_symbol_address bgf_generic_real_symbol_address
 #define som_get_lineno			_bfd_nosymbols_get_lineno
 #define som_bfd_make_debug_symbol	_bfd_nosymbols_bfd_make_debug_symbol
 #define som_read_minisymbols		_bfd_generic_read_minisymbols
Index: bfd/srec.c
===================================================================
RCS file: /cvs/src/src/bfd/srec.c,v
retrieving revision 1.32
diff -u -p -r1.32 srec.c
--- bfd/srec.c	8 Oct 2004 14:54:01 -0000	1.32
+++ bfd/srec.c	29 Oct 2004 20:22:24 -0000
@@ -1263,6 +1263,7 @@ srec_print_symbol (abfd, afile, symbol, 
 #define srec_new_section_hook _bfd_generic_new_section_hook
 
 #define srec_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
+#define srec_real_symbol_address bfd_generic_real_symbol_address
 #define srec_bfd_is_local_label_name bfd_generic_is_local_label_name
 #define srec_get_lineno _bfd_nosymbols_get_lineno
 #define srec_find_nearest_line _bfd_nosymbols_find_nearest_line
Index: bfd/syms.c
===================================================================
RCS file: /cvs/src/src/bfd/syms.c,v
retrieving revision 1.39
diff -u -p -r1.39 syms.c
--- bfd/syms.c	8 Oct 2004 14:54:01 -0000	1.39
+++ bfd/syms.c	29 Oct 2004 20:22:24 -0000
@@ -399,6 +399,29 @@ DESCRIPTION
 
 /*
 FUNCTION
+	bfd_real_symbol_address
+
+SYNOPSIS
+        bfd_vma bfd_real_symbol_address (bfd *abfd, asymbol *sym);
+
+DESCRIPTION
+	Some targets use spare address bits encode auxiliary information
+	about the symbol (eg. arm/thumb).  This returns the actual
+	VM address refered to be the symbol.
+
+.#define bfd_real_symbol_address(sym) \
+.  BFD_SEND (sym->the_bfd, _real_symbol_address, (sym))
+.
+*/
+
+bfd_vma
+bfd_generic_real_symbol_address (asymbol * sym)
+{
+  return bfd_asymbol_value (sym);
+}
+
+/*
+FUNCTION
 	bfd_canonicalize_symtab
 
 DESCRIPTION
Index: bfd/targets.c
===================================================================
RCS file: /cvs/src/src/bfd/targets.c,v
retrieving revision 1.118
diff -u -p -r1.118 targets.c
--- bfd/targets.c	8 Oct 2004 14:54:01 -0000	1.118
+++ bfd/targets.c	29 Oct 2004 20:22:25 -0000
@@ -339,6 +339,7 @@ BFD_JUMP_TABLE macros.
 .  NAME##_get_symbol_info, \
 .  NAME##_bfd_is_local_label_name, \
 .  NAME##_bfd_is_target_special_symbol, \
+.  NAME##_real_symbol_address, \
 .  NAME##_get_lineno, \
 .  NAME##_find_nearest_line, \
 .  NAME##_bfd_make_debug_symbol, \
@@ -358,6 +359,7 @@ BFD_JUMP_TABLE macros.
 .#define bfd_get_symbol_info(b,p,e) BFD_SEND (b, _bfd_get_symbol_info, (b,p,e))
 .  bfd_boolean (*_bfd_is_local_label_name) (bfd *, const char *);
 .  bfd_boolean (*_bfd_is_target_special_symbol) (bfd *, asymbol *);
+.  bfd_vma     (*_real_symbol_address) (asymbol *);
 .  alent *     (*_get_lineno) (bfd *, struct bfd_symbol *);
 .  bfd_boolean (*_bfd_find_nearest_line)
 .    (bfd *, struct bfd_section *, struct bfd_symbol **, bfd_vma,
Index: bfd/tekhex.c
===================================================================
RCS file: /cvs/src/src/bfd/tekhex.c,v
retrieving revision 1.22
diff -u -p -r1.22 tekhex.c
--- bfd/tekhex.c	8 Oct 2004 14:54:02 -0000	1.22
+++ bfd/tekhex.c	29 Oct 2004 20:22:25 -0000
@@ -990,6 +990,7 @@ tekhex_print_symbol (abfd, filep, symbol
 #define tekhex_new_section_hook _bfd_generic_new_section_hook
 
 #define tekhex_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
+#define tekhex_real_symbol_address bfd_generic_real_symbol_address
 #define tekhex_bfd_is_local_label_name bfd_generic_is_local_label_name
 #define tekhex_get_lineno _bfd_nosymbols_get_lineno
 #define tekhex_find_nearest_line _bfd_nosymbols_find_nearest_line
Index: bfd/versados.c
===================================================================
RCS file: /cvs/src/src/bfd/versados.c,v
retrieving revision 1.24
diff -u -p -r1.24 versados.c
--- bfd/versados.c	8 Oct 2004 14:54:02 -0000	1.24
+++ bfd/versados.c	29 Oct 2004 20:22:25 -0000
@@ -857,6 +857,7 @@ versados_canonicalize_reloc (abfd, secti
 
 #define versados_bfd_is_target_special_symbol \
   ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
+#define versados_real_symbol_address bfd_generic_real_symbol_address
 #define versados_bfd_is_local_label_name bfd_generic_is_local_label_name
 #define versados_get_lineno _bfd_nosymbols_get_lineno
 #define versados_find_nearest_line _bfd_nosymbols_find_nearest_line
Index: bfd/vms.c
===================================================================
RCS file: /cvs/src/src/bfd/vms.c,v
retrieving revision 1.32
diff -u -p -r1.32 vms.c
--- bfd/vms.c	8 Oct 2004 14:54:02 -0000	1.32
+++ bfd/vms.c	29 Oct 2004 20:22:25 -0000
@@ -165,6 +165,7 @@ static bfd_boolean vms_bfd_set_private_f
   PARAMS ((bfd *abfd, flagword flags));
 
 #define vms_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
+#define vms_real_symbol_address bfd_generic_real_symbol_address
 #define vms_make_empty_symbol _bfd_generic_make_empty_symbol
 #define vms_bfd_link_just_syms _bfd_generic_link_just_syms
 #define vms_bfd_is_group_section bfd_generic_is_group_section
Index: bfd/xcoff-target.h
===================================================================
RCS file: /cvs/src/src/bfd/xcoff-target.h,v
retrieving revision 1.11
diff -u -p -r1.11 xcoff-target.h
--- bfd/xcoff-target.h	8 Oct 2004 14:54:02 -0000	1.11
+++ bfd/xcoff-target.h	29 Oct 2004 20:22:26 -0000
@@ -44,6 +44,7 @@ Foundation, Inc., 59 Temple Place - Suit
 #define coff_bfd_copy_private_bfd_data _bfd_xcoff_copy_private_bfd_data
 #define coff_bfd_is_local_label_name _bfd_xcoff_is_local_label_name
 #define coff_bfd_is_target_special_symbol  ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
+#define coff_real_symbol_address bfd_generic_real_symbol_address
 #define coff_bfd_reloc_type_lookup _bfd_xcoff_reloc_type_lookup
 #define coff_relocate_section _bfd_ppc_xcoff_relocate_section
 
Index: bfd/xsym.c
===================================================================
RCS file: /cvs/src/src/bfd/xsym.c,v
retrieving revision 1.9
diff -u -p -r1.9 xsym.c
--- bfd/xsym.c	8 Oct 2004 14:54:02 -0000	1.9
+++ bfd/xsym.c	29 Oct 2004 20:22:26 -0000
@@ -28,6 +28,7 @@
 #define bfd_sym_new_section_hook _bfd_generic_new_section_hook
 #define bfd_sym_bfd_is_local_label_name bfd_generic_is_local_label_name
 #define bfd_sym_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
+#define bfd_sym_real_symbol_address bfd_generic_real_symbol_address
 #define bfd_sym_get_lineno _bfd_nosymbols_get_lineno
 #define bfd_sym_find_nearest_line _bfd_nosymbols_find_nearest_line
 #define bfd_sym_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
Index: binutils/objdump.c
===================================================================
RCS file: /cvs/src/src/binutils/objdump.c,v
retrieving revision 1.96
diff -u -p -r1.96 objdump.c
--- binutils/objdump.c	11 Oct 2004 08:18:43 -0000	1.96
+++ binutils/objdump.c	29 Oct 2004 20:22:27 -0000
@@ -695,9 +695,9 @@ find_symbol_for_address (bfd_vma vma,
       thisplace = (max + min) / 2;
       sym = sorted_syms[thisplace];
 
-      if (bfd_asymbol_value (sym) > vma)
+      if (bfd_real_symbol_address (sym) > vma)
 	max = thisplace;
-      else if (bfd_asymbol_value (sym) < vma)
+      else if (bfd_real_symbol_address (sym) < vma)
 	min = thisplace;
       else
 	{
@@ -711,8 +711,8 @@ find_symbol_for_address (bfd_vma vma,
      value, we want the first one.  */
   thisplace = min;
   while (thisplace > 0
-	 && (bfd_asymbol_value (sorted_syms[thisplace])
-	     == bfd_asymbol_value (sorted_syms[thisplace - 1])))
+	 && (bfd_real_symbol_address (sorted_syms[thisplace])
+	     == bfd_real_symbol_address (sorted_syms[thisplace - 1])))
     --thisplace;
 
   /* If the file is relocatable, and the symbol could be from this
@@ -734,8 +734,8 @@ find_symbol_for_address (bfd_vma vma,
 
       for (i = thisplace + 1; i < sorted_symcount; i++)
 	{
-	  if (bfd_asymbol_value (sorted_syms[i])
-	      != bfd_asymbol_value (sorted_syms[thisplace]))
+	  if (bfd_real_symbol_address (sorted_syms[i])
+	      != bfd_real_symbol_address (sorted_syms[thisplace]))
 	    break;
 	}
 
@@ -746,8 +746,8 @@ find_symbol_for_address (bfd_vma vma,
 	  if (sorted_syms[i]->section == sec
 	      && (i == 0
 		  || sorted_syms[i - 1]->section != sec
-		  || (bfd_asymbol_value (sorted_syms[i])
-		      != bfd_asymbol_value (sorted_syms[i - 1]))))
+		  || (bfd_real_symbol_address (sorted_syms[i])
+		      != bfd_real_symbol_address (sorted_syms[i - 1]))))
 	    {
 	      thisplace = i;
 	      break;
@@ -783,7 +783,7 @@ find_symbol_for_address (bfd_vma vma,
     {
       ++ thisplace;
       if (thisplace >= sorted_symcount
-	  || bfd_asymbol_value (sorted_syms [thisplace]) > vma)
+	  || bfd_real_symbol_address (sorted_syms [thisplace]) > vma)
 	return NULL;
     }
 
@@ -825,15 +825,17 @@ objdump_print_addr_with_sym (bfd *abfd, 
     {
       (*info->fprintf_func) (info->stream, " <");
       objdump_print_symname (abfd, info, sym);
-      if (bfd_asymbol_value (sym) > vma)
+      if (bfd_real_symbol_address (sym) > vma)
 	{
 	  (*info->fprintf_func) (info->stream, "-0x");
-	  objdump_print_value (bfd_asymbol_value (sym) - vma, info, TRUE);
+	  objdump_print_value (bfd_real_symbol_address (sym) - vma, info,
+			       TRUE);
 	}
-      else if (vma > bfd_asymbol_value (sym))
+      else if (vma > bfd_real_symbol_address (sym))
 	{
 	  (*info->fprintf_func) (info->stream, "+0x");
-	  objdump_print_value (vma - bfd_asymbol_value (sym), info, TRUE);
+	  objdump_print_value (vma - bfd_real_symbol_address (sym), info,
+			       TRUE);
 	}
       (*info->fprintf_func) (info->stream, ">");
     }
@@ -881,7 +883,7 @@ objdump_symbol_at_address (bfd_vma vma, 
 
   sym = find_symbol_for_address (vma, info, NULL);
 
-  return (sym != NULL && (bfd_asymbol_value (sym) == vma));
+  return (sym != NULL && (bfd_real_symbol_address (sym) == vma));
 }
 
 /* Hold the last function name and the last line number we displayed
@@ -1686,13 +1688,13 @@ disassemble_section (bfd *abfd, asection
 
       addr = section->vma + addr_offset;
 
-      if (sym != NULL && bfd_asymbol_value (sym) <= addr)
+      if (sym != NULL && bfd_real_symbol_address (sym) <= addr)
 	{
 	  int x;
 
 	  for (x = place;
 	       (x < sorted_symcount
-		&& (bfd_asymbol_value (sorted_syms[x]) <= addr));
+		&& (bfd_real_symbol_address (sorted_syms[x]) <= addr));
 	       ++x)
 	    continue;
 
@@ -1713,7 +1715,7 @@ disassemble_section (bfd *abfd, asection
 	  pinfo->fprintf_func (pinfo->stream, ":\n");
 	}
 
-      if (sym != NULL && bfd_asymbol_value (sym) > addr)
+      if (sym != NULL && bfd_real_symbol_address (sym) > addr)
 	nextsym = sym;
       else if (sym == NULL)
 	nextsym = NULL;
@@ -1721,7 +1723,7 @@ disassemble_section (bfd *abfd, asection
 	{
 #define is_valid_next_sym(SYM) \
   ((SYM)->section == section \
-   && (bfd_asymbol_value (SYM) > bfd_asymbol_value (sym)) \
+   && (bfd_real_symbol_address (SYM) > bfd_real_symbol_address (sym)) \
    && pinfo->symbol_is_valid (SYM, pinfo))
 	    
 	  /* Search forward for the next appropriate symbol in
@@ -1738,12 +1740,12 @@ disassemble_section (bfd *abfd, asection
 	    nextsym = sorted_syms[place];
 	}
 
-      if (sym != NULL && bfd_asymbol_value (sym) > addr)
-	nextstop_offset = bfd_asymbol_value (sym) - section->vma;
+      if (sym != NULL && bfd_real_symbol_address (sym) > addr)
+	nextstop_offset = bfd_real_symbol_address (sym) - section->vma;
       else if (nextsym == NULL)
 	nextstop_offset = stop_offset;
       else
-	nextstop_offset = bfd_asymbol_value (nextsym) - section->vma;
+	nextstop_offset = bfd_real_symbol_address (nextsym) - section->vma;
 
       if (nextstop_offset > stop_offset)
 	nextstop_offset = stop_offset;
@@ -1753,7 +1755,7 @@ disassemble_section (bfd *abfd, asection
 	 disassembling them.  */
       if (disassemble_all
 	  || sym == NULL
-	  || bfd_asymbol_value (sym) > addr
+	  || bfd_real_symbol_address (sym) > addr
 	  || ((sym->flags & BSF_OBJECT) == 0
 	      && (strstr (bfd_asymbol_name (sym), "gnu_compiled")
 		  == NULL)
Index: gas/config/tc-arm.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-arm.c,v
retrieving revision 1.184
diff -u -p -r1.184 tc-arm.c
--- gas/config/tc-arm.c	25 Oct 2004 12:26:01 -0000	1.184
+++ gas/config/tc-arm.c	29 Oct 2004 20:22:29 -0000
@@ -13370,19 +13370,29 @@ arm_adjust_symtab (void)
     {
       if (ARM_IS_THUMB (sym))
 	{
-	  elf_symbol_type * elf_sym;
 
-	  elf_sym = elf_symbol (symbol_get_bfdsym (sym));
-	  bind = ELF_ST_BIND (elf_sym);
-
-	  /* If it's a .thumb_func, declare it as so,
-	     otherwise tag label as .code 16.  */
-	  if (THUMB_IS_FUNC (sym))
-	    elf_sym->internal_elf_sym.st_info =
-	      ELF_ST_INFO (bind, STT_ARM_TFUNC);
+	  if (meabi_flags == EF_ARM_EABI_VER4)
+	    {
+	      /* Set the low bit on thumb symbols.  */
+	      if (THUMB_IS_FUNC (sym))
+		symbol_get_bfdsym (sym)->value |= 1;
+	    }
 	  else
-	    elf_sym->internal_elf_sym.st_info =
-	      ELF_ST_INFO (bind, STT_ARM_16BIT);
+	    {
+	      elf_symbol_type * elf_sym;
+
+	      elf_sym = elf_symbol (symbol_get_bfdsym (sym));
+	      bind = ELF_ST_BIND (elf_sym);
+
+	      /* If it's a .thumb_func, declare it as so,
+		 otherwise tag label as .code 16.  */
+	      if (THUMB_IS_FUNC (sym))
+		elf_sym->internal_elf_sym.st_info =
+		  ELF_ST_INFO (bind, STT_ARM_TFUNC);
+	      else
+		elf_sym->internal_elf_sym.st_info =
+		  ELF_ST_INFO (bind, STT_ARM_16BIT);
+	    }
 	}
     }
 #endif
Index: opcodes/arm-dis.c
===================================================================
RCS file: /cvs/src/src/opcodes/arm-dis.c,v
retrieving revision 1.38
diff -u -p -r1.38 arm-dis.c
--- opcodes/arm-dis.c	30 Sep 2004 16:21:43 -0000	1.38
+++ opcodes/arm-dis.c	29 Oct 2004 20:22:31 -0000
@@ -1286,7 +1286,8 @@ print_insn (pc, info, little)
 	  es = *(elf_symbol_type **)(info->symbols);
 	  type = ELF_ST_TYPE (es->internal_elf_sym.st_info);
 
-	  is_thumb = (type == STT_ARM_TFUNC) || (type == STT_ARM_16BIT);
+	  is_thumb = (type == STT_ARM_TFUNC) || (type == STT_ARM_16BIT)
+	    || (type == STT_FUNC && (es->internal_elf_sym.st_value & 1));
 	}
     }
 

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

* Re: [arm] EABI annotation of thumb symbols.
  2004-11-02 14:22 [arm] EABI annotation of thumb symbols Paul Brook
@ 2004-11-02 14:41 ` Richard Earnshaw
  2004-11-02 15:12   ` Daniel Jacobowitz
  2004-11-02 15:06 ` Ian Lance Taylor
  1 sibling, 1 reply; 15+ messages in thread
From: Richard Earnshaw @ 2004-11-02 14:41 UTC (permalink / raw)
  To: Paul Brook; +Cc: binutils

On Tue, 2004-11-02 at 14:22, Paul Brook wrote:
> The current Arm abi  identifies thumb function symbols by giving them type 
> STT_ARM_TFUNC.
> 
> The Arm EABI specifies that thumb function symbols should be identified by 
> setting the least significant bit of the address, and type STT_FUNC.
> 
> The patch below implements this. The main complication is that objdump -d 
> breaks. I added a new bfd function to get the real address of a symbol. This 
> seemed preferable to trying to mangle symbols while reading them in.
> 
> I'm open to alternative suggestions if people think this is the wrong way to 
> implement this.

Another alternative, which might be less invasive on other parts of the
tools is to have the ARM symbol slurp and write code translate the ABI
v4 format into the STT_ARM_TFUNC internally when the symbol table is
read and vice versa when it is written.

Then the internal value of the symbol would always be the correct
'address' rather than the mangled address.

Put another way, the LSB being set on the symbol in the object file is
just a different way of encoding the STT_ARM_TFUNC feature.

R.

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

* Re: [arm] EABI annotation of thumb symbols.
  2004-11-02 14:22 [arm] EABI annotation of thumb symbols Paul Brook
  2004-11-02 14:41 ` Richard Earnshaw
@ 2004-11-02 15:06 ` Ian Lance Taylor
  1 sibling, 0 replies; 15+ messages in thread
From: Ian Lance Taylor @ 2004-11-02 15:06 UTC (permalink / raw)
  To: Paul Brook; +Cc: binutils, Richard Earnshaw

Paul Brook <paul@codesourcery.com> writes:

> The patch below implements this. The main complication is that objdump -d 
> breaks. I added a new bfd function to get the real address of a symbol. This 
> seemed preferable to trying to mangle symbols while reading them in.
> 
> I'm open to alternative suggestions if people think this is the wrong way to 
> implement this.

I think this is the wrong way to implement this.  It introduces a new
function with rather unclear semantics.  When is a program supposed to
call bfd_real_symbol_address()?  Why don't you have to change nm.c and
ar.c while you are at it?

Richard's suggestion of mangling the values on the way in seems
plausible.  Alternatively, add a new disassembler hook to frob the
symbol table.

Ian

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

* Re: [arm] EABI annotation of thumb symbols.
  2004-11-02 14:41 ` Richard Earnshaw
@ 2004-11-02 15:12   ` Daniel Jacobowitz
  2004-11-04  1:55     ` Ian Lance Taylor
  0 siblings, 1 reply; 15+ messages in thread
From: Daniel Jacobowitz @ 2004-11-02 15:12 UTC (permalink / raw)
  To: Richard Earnshaw; +Cc: Paul Brook, binutils

On Tue, Nov 02, 2004 at 02:41:10PM +0000, Richard Earnshaw wrote:
> On Tue, 2004-11-02 at 14:22, Paul Brook wrote:
> > The current Arm abi  identifies thumb function symbols by giving them type 
> > STT_ARM_TFUNC.
> > 
> > The Arm EABI specifies that thumb function symbols should be identified by 
> > setting the least significant bit of the address, and type STT_FUNC.
> > 
> > The patch below implements this. The main complication is that objdump -d 
> > breaks. I added a new bfd function to get the real address of a symbol. This 
> > seemed preferable to trying to mangle symbols while reading them in.
> > 
> > I'm open to alternative suggestions if people think this is the wrong way to 
> > implement this.
> 
> Another alternative, which might be less invasive on other parts of the
> tools is to have the ARM symbol slurp and write code translate the ABI
> v4 format into the STT_ARM_TFUNC internally when the symbol table is
> read and vice versa when it is written.
> 
> Then the internal value of the symbol would always be the correct
> 'address' rather than the mangled address.
> 
> Put another way, the LSB being set on the symbol in the object file is
> just a different way of encoding the STT_ARM_TFUNC feature.

I think that's an excellent idea.  GDB still hasn't recovered from the
addition of mapping symbols to the symbol table; messing with the
addresses of Thumb symbols would probably confuse it beyond redemption.

[This was one of the last open issues I had questions about before
posting the Thumb PLT patches I've mentioned before.  I will try to do
that Really, Really Soon, like this afternoon.]

-- 
Daniel Jacobowitz

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

* Re: [arm] EABI annotation of thumb symbols.
  2004-11-02 15:12   ` Daniel Jacobowitz
@ 2004-11-04  1:55     ` Ian Lance Taylor
  2004-11-04 10:20       ` Richard Earnshaw
  0 siblings, 1 reply; 15+ messages in thread
From: Ian Lance Taylor @ 2004-11-04  1:55 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: Richard Earnshaw, Paul Brook, binutils

Daniel Jacobowitz <drow@false.org> writes:

> [This was one of the last open issues I had questions about before
> posting the Thumb PLT patches I've mentioned before.  I will try to do
> that Really, Really Soon, like this afternoon.]

I was thinking about Thumb PLT earlier.  I can see how to get each PLT
entry down to 8 bytes, but the linker would have to strew various
branches across the PLT to get around the limited range of the Thumb
branch instruction.  Is that the type of thing you are doing?

Ian

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

* Re: [arm] EABI annotation of thumb symbols.
  2004-11-04  1:55     ` Ian Lance Taylor
@ 2004-11-04 10:20       ` Richard Earnshaw
  2004-11-04 14:19         ` Daniel Jacobowitz
  2004-11-04 15:03         ` Ian Lance Taylor
  0 siblings, 2 replies; 15+ messages in thread
From: Richard Earnshaw @ 2004-11-04 10:20 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: Daniel Jacobowitz, Paul Brook, binutils

On Thu, 2004-11-04 at 01:54, Ian Lance Taylor wrote:
> Daniel Jacobowitz <drow@false.org> writes:
> 
> > [This was one of the last open issues I had questions about before
> > posting the Thumb PLT patches I've mentioned before.  I will try to do
> > that Really, Really Soon, like this afternoon.]
> 
> I was thinking about Thumb PLT earlier.  I can see how to get each PLT
> entry down to 8 bytes, but the linker would have to strew various
> branches across the PLT to get around the limited range of the Thumb
> branch instruction.  Is that the type of thing you are doing?

Don't do Thumb PLT's.  The idea doesn't work.

        1) You don't know whether the target will be ARM or Thumb (it's
        in another shared library which may not be the same at run time
        as the one you link against at static link time -- don't forget
        pre-emption).  So the sequence has to end with an instruction
        that can change instruction set state (on v4T that means bx).
        
        2) You don't have enough registers to do a bx at the end of the
        sequence and remember where you've come from (Needed for
        re-entry into the dynamic linker, especially if you want to
        continue to support pre-linking).  To avoid this you end up
        playing games that make the sequence as long as any ARM
        equivalent -- and there are still problems.
        
We concluded that the best solution on v4T chips was to insist that all
shared library functions were entered in ARM state (they can switch back
to Thumb internally); it the linker's job to create the proper entry
points when building a shared library.  In libraries that will run on v5
or later systems, the restriction can be lifted, since an ldr to the PC
can switch to Thumb state without problems.

All this means that the PLT sequences should be written using ARM
instructions and end with an instruction that loads into the PC the
address of the function to call.  In effect the sequence is

	ADRL	ip, PLTGOT_FOR_TARGET
	ldr	pc, [ip]

Typically the ADRL instruction will be two or three ADD instructions.

R.

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

* Re: [arm] EABI annotation of thumb symbols.
  2004-11-04 10:20       ` Richard Earnshaw
@ 2004-11-04 14:19         ` Daniel Jacobowitz
  2004-11-04 14:33           ` Richard Earnshaw
  2004-11-04 15:03         ` Ian Lance Taylor
  1 sibling, 1 reply; 15+ messages in thread
From: Daniel Jacobowitz @ 2004-11-04 14:19 UTC (permalink / raw)
  To: Richard Earnshaw; +Cc: Ian Lance Taylor, Paul Brook, binutils

On Thu, Nov 04, 2004 at 10:20:44AM +0000, Richard Earnshaw wrote:
> On Thu, 2004-11-04 at 01:54, Ian Lance Taylor wrote:
> > Daniel Jacobowitz <drow@false.org> writes:
> > 
> > > [This was one of the last open issues I had questions about before
> > > posting the Thumb PLT patches I've mentioned before.  I will try to do
> > > that Really, Really Soon, like this afternoon.]
> > 
> > I was thinking about Thumb PLT earlier.  I can see how to get each PLT
> > entry down to 8 bytes, but the linker would have to strew various
> > branches across the PLT to get around the limited range of the Thumb
> > branch instruction.  Is that the type of thing you are doing?
> 
> Don't do Thumb PLT's.  The idea doesn't work.

Yes.  Sorry I was unclear; I meant "PLTs usable from Thumb".  It could
be done somewhat more efficiently than the way I did it for v5 (by
editing branches in the input), but I just put Thumb-to-ARM stubs in
the right place.  Once the OABI code has been dealt with I'll post it,
really.

>         1) You don't know whether the target will be ARM or Thumb (it's
>         in another shared library which may not be the same at run time
>         as the one you link against at static link time -- don't forget
>         pre-emption).  So the sequence has to end with an instruction
>         that can change instruction set state (on v4T that means bx).
>         
>         2) You don't have enough registers to do a bx at the end of the
>         sequence and remember where you've come from (Needed for
>         re-entry into the dynamic linker, especially if you want to
>         continue to support pre-linking).  To avoid this you end up
>         playing games that make the sequence as long as any ARM
>         equivalent -- and there are still problems.
>         
> We concluded that the best solution on v4T chips was to insist that all
> shared library functions were entered in ARM state (they can switch back
> to Thumb internally); it the linker's job to create the proper entry
> points when building a shared library.  In libraries that will run on v5
> or later systems, the restriction can be lifted, since an ldr to the PC
> can switch to Thumb state without problems.

I've actually implemented the alternative suggested in a document
someone (you?  Phil?) posted to the EABI list at some point, in which
GOT entries point back into the proper PLT stub.  This supports
entering shared libraries in Thumb mode on V4T.  However, I'm quite
willing to ditch that part of the patch, and try to implement
generating ARM entry points instead.

-- 
Daniel Jacobowitz

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

* Re: [arm] EABI annotation of thumb symbols.
  2004-11-04 14:19         ` Daniel Jacobowitz
@ 2004-11-04 14:33           ` Richard Earnshaw
  2004-11-04 15:10             ` Daniel Jacobowitz
  0 siblings, 1 reply; 15+ messages in thread
From: Richard Earnshaw @ 2004-11-04 14:33 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: Ian Lance Taylor, Paul Brook, binutils

On Thu, 2004-11-04 at 14:19, Daniel Jacobowitz wrote:

> I've actually implemented the alternative suggested in a document
> someone (you?  Phil?) posted to the EABI list at some point, in which
> GOT entries point back into the proper PLT stub.  This supports
> entering shared libraries in Thumb mode on V4T.  However, I'm quite
> willing to ditch that part of the patch, and try to implement
> generating ARM entry points instead.

Another problem with the v4T interworking clean solution is that it
relies on an instruction that isn't available on V4 or earlier.

That means that the linker *HAS* to know what system it is targeting. 
The v5 solution (with shared libraries entered on v4T in ARM state)
avoids that problem and gives a PLT sequence which will work on all
architectures.

And of course, all the solutions we discussed privately for supporting
pre-linking were at best a bit cludgy, and at worst, outright hacks
(unless you came up with another solution to that problem).

R.

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

* Re: [arm] EABI annotation of thumb symbols.
  2004-11-04 10:20       ` Richard Earnshaw
  2004-11-04 14:19         ` Daniel Jacobowitz
@ 2004-11-04 15:03         ` Ian Lance Taylor
  2004-11-04 15:08           ` Daniel Jacobowitz
  2004-11-04 15:47           ` Richard Earnshaw
  1 sibling, 2 replies; 15+ messages in thread
From: Ian Lance Taylor @ 2004-11-04 15:03 UTC (permalink / raw)
  To: Richard Earnshaw; +Cc: Daniel Jacobowitz, Paul Brook, binutils

Richard Earnshaw <rearnsha@arm.com> writes:

> Don't do Thumb PLT's.  The idea doesn't work.
> 
>         1) You don't know whether the target will be ARM or Thumb (it's
>         in another shared library which may not be the same at run time
>         as the one you link against at static link time -- don't forget
>         pre-emption).  So the sequence has to end with an instruction
>         that can change instruction set state (on v4T that means bx).
>         
>         2) You don't have enough registers to do a bx at the end of the
>         sequence and remember where you've come from (Needed for
>         re-entry into the dynamic linker, especially if you want to
>         continue to support pre-linking).  To avoid this you end up
>         playing games that make the sequence as long as any ARM
>         equivalent -- and there are still problems.

I certainly agree that Thumb PLTs are only useful on v5t and up.  For
my purposes, that is OK, since our customers use XScale chips.

That said, I'm building Thumb shared libraries in which the PLT takes
up 120K, or some 4.5% of the text section size.  It's probably
possible to use version scripts to force some of the symbols to be
local, but this source code is neither from us nor from our customer,
so that is not a simple task.  Using Thumb instructions in the PLT
would give me some clearly measurable size improvements.

Ian

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

* Re: [arm] EABI annotation of thumb symbols.
  2004-11-04 15:03         ` Ian Lance Taylor
@ 2004-11-04 15:08           ` Daniel Jacobowitz
  2004-11-04 15:42             ` Ian Lance Taylor
  2004-11-04 15:47           ` Richard Earnshaw
  1 sibling, 1 reply; 15+ messages in thread
From: Daniel Jacobowitz @ 2004-11-04 15:08 UTC (permalink / raw)
  To: paul, binutils, rearnsha

On Thu, Nov 04, 2004 at 10:03:25AM -0500, Ian Lance Taylor wrote:
> Richard Earnshaw <rearnsha@arm.com> writes:
> 
> > Don't do Thumb PLT's.  The idea doesn't work.
> > 
> >         1) You don't know whether the target will be ARM or Thumb (it's
> >         in another shared library which may not be the same at run time
> >         as the one you link against at static link time -- don't forget
> >         pre-emption).  So the sequence has to end with an instruction
> >         that can change instruction set state (on v4T that means bx).
> >         
> >         2) You don't have enough registers to do a bx at the end of the
> >         sequence and remember where you've come from (Needed for
> >         re-entry into the dynamic linker, especially if you want to
> >         continue to support pre-linking).  To avoid this you end up
> >         playing games that make the sequence as long as any ARM
> >         equivalent -- and there are still problems.
> 
> I certainly agree that Thumb PLTs are only useful on v5t and up.  For
> my purposes, that is OK, since our customers use XScale chips.
> 
> That said, I'm building Thumb shared libraries in which the PLT takes
> up 120K, or some 4.5% of the text section size.  It's probably
> possible to use version scripts to force some of the symbols to be
> local, but this source code is neither from us nor from our customer,
> so that is not a simple task.  Using Thumb instructions in the PLT
> would give me some clearly measurable size improvements.

Would it really?  Here's an alternative: in the patches I'll be
posting, I add support for independently sized PLT entries.  It would
then be relatively simple (not trivial, because of relaxation problems,
but doable) to use a two instruction ARM PLT sequence if it is in
range.  The largest shared library I have handy at the moment has an
85K PLT using the new three-word entries, and the first word is
_always_ redundant.  Then use interworking branches to get to the PLT.

I doubt you'll get a Thumb PLT sequence under eight bytes.

-- 
Daniel Jacobowitz

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

* Re: [arm] EABI annotation of thumb symbols.
  2004-11-04 14:33           ` Richard Earnshaw
@ 2004-11-04 15:10             ` Daniel Jacobowitz
  0 siblings, 0 replies; 15+ messages in thread
From: Daniel Jacobowitz @ 2004-11-04 15:10 UTC (permalink / raw)
  To: Richard Earnshaw; +Cc: Ian Lance Taylor, Paul Brook, binutils

On Thu, Nov 04, 2004 at 02:33:26PM +0000, Richard Earnshaw wrote:
> On Thu, 2004-11-04 at 14:19, Daniel Jacobowitz wrote:
> 
> > I've actually implemented the alternative suggested in a document
> > someone (you?  Phil?) posted to the EABI list at some point, in which
> > GOT entries point back into the proper PLT stub.  This supports
> > entering shared libraries in Thumb mode on V4T.  However, I'm quite
> > willing to ditch that part of the patch, and try to implement
> > generating ARM entry points instead.
> 
> Another problem with the v4T interworking clean solution is that it
> relies on an instruction that isn't available on V4 or earlier.
> 
> That means that the linker *HAS* to know what system it is targeting. 
> The v5 solution (with shared libraries entered on v4T in ARM state)
> avoids that problem and gives a PLT sequence which will work on all
> architectures.

That's true (and very nice).  My implementation relied on the ELF
header flags, which are not EABI-friendly as I understand it.

> And of course, all the solutions we discussed privately for supporting
> pre-linking were at best a bit cludgy, and at worst, outright hacks
> (unless you came up with another solution to that problem).

Nope.  Quite disgusting; I never did the prelink-side implementation.

-- 
Daniel Jacobowitz

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

* Re: [arm] EABI annotation of thumb symbols.
  2004-11-04 15:08           ` Daniel Jacobowitz
@ 2004-11-04 15:42             ` Ian Lance Taylor
  2004-11-04 15:49               ` Daniel Jacobowitz
  0 siblings, 1 reply; 15+ messages in thread
From: Ian Lance Taylor @ 2004-11-04 15:42 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: paul, binutils, rearnsha

Daniel Jacobowitz <drow@false.org> writes:

> > That said, I'm building Thumb shared libraries in which the PLT takes
> > up 120K, or some 4.5% of the text section size.  It's probably
> > possible to use version scripts to force some of the symbols to be
> > local, but this source code is neither from us nor from our customer,
> > so that is not a simple task.  Using Thumb instructions in the PLT
> > would give me some clearly measurable size improvements.
> 
> Would it really?  Here's an alternative: in the patches I'll be
> posting, I add support for independently sized PLT entries.  It would
> then be relatively simple (not trivial, because of relaxation problems,
> but doable) to use a two instruction ARM PLT sequence if it is in
> range.  The largest shared library I have handy at the moment has an
> 85K PLT using the new three-word entries, and the first word is
> _always_ redundant.  Then use interworking branches to get to the PLT.
> 
> I doubt you'll get a Thumb PLT sequence under eight bytes.

I don't know what the three-word PLT entry is.  By relaxation, do you
mean loading a GOT index into a register and then branching to the
symbol resolution routine?  That would work for the first 256 GOT
entries, and for some subset of the subsequent ones.  Or did you have
something else in mind?

The eight-byte Thumb sequence includes the offset word, and relies on
branching to common code to do the rest of the work.  I agree that it
is unlikely to get smaller than that.

Ian

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

* Re: [arm] EABI annotation of thumb symbols.
  2004-11-04 15:03         ` Ian Lance Taylor
  2004-11-04 15:08           ` Daniel Jacobowitz
@ 2004-11-04 15:47           ` Richard Earnshaw
  2004-11-04 16:01             ` Ian Lance Taylor
  1 sibling, 1 reply; 15+ messages in thread
From: Richard Earnshaw @ 2004-11-04 15:47 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: Daniel Jacobowitz, Paul Brook, binutils

On Thu, 2004-11-04 at 15:03, Ian Lance Taylor wrote:
> Richard Earnshaw <rearnsha@arm.com> writes:
> 
> > Don't do Thumb PLT's.  The idea doesn't work.
> > 
> >         1) You don't know whether the target will be ARM or Thumb (it's
> >         in another shared library which may not be the same at run time
> >         as the one you link against at static link time -- don't forget
> >         pre-emption).  So the sequence has to end with an instruction
> >         that can change instruction set state (on v4T that means bx).
> >         
> >         2) You don't have enough registers to do a bx at the end of the
> >         sequence and remember where you've come from (Needed for
> >         re-entry into the dynamic linker, especially if you want to
> >         continue to support pre-linking).  To avoid this you end up
> >         playing games that make the sequence as long as any ARM
> >         equivalent -- and there are still problems.
> 
> I certainly agree that Thumb PLTs are only useful on v5t and up.  For
> my purposes, that is OK, since our customers use XScale chips.
> 
> That said, I'm building Thumb shared libraries in which the PLT takes
> up 120K, or some 4.5% of the text section size.  It's probably
> possible to use version scripts to force some of the symbols to be
> local, but this source code is neither from us nor from our customer,
> so that is not a simple task.  Using Thumb instructions in the PLT
> would give me some clearly measurable size improvements.

Ultimately it depends on the performance you want out of your code.  If
performance is not a goal at all, then you could probably squeeze each
PLT stub down to about 4 bytes, with

	mov	ip, pc
	b	common_plt

(and if the plt cannot reach common_plt, then chain it to one that
can).  common_plt can do all manner of things, provided that at the
point at which it calls into the target function things are set up
correctly in case we end up in the dynamic linker.  But remember that
the sequence above depends critically on each PLT sequence being the
same length and on them all being located sequentially in memory (so
that the PC value can be converted algorithmically into a PLTGOT value).

The critical thing about PLT stubs is not the code that you execute in
them as much as the values in registers if you end up entering the
dynamic linker.  There a number of constraints there, especially if we
want to maintain some semblance of compatibility with existing code.

So, the ABI does not lay down what a PLT sequence must be.  It does,
however, lay down the constraints that such a sequence must meet in
order to permit dynamic linking (if you do all your linking off-line, or
don't want to permit lazy binding then some of those constraints can be
lifted as well).  In particular, IP must point at the PLTGOT slot so
that the dynamic linker can patch the correct place.

R.

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

* Re: [arm] EABI annotation of thumb symbols.
  2004-11-04 15:42             ` Ian Lance Taylor
@ 2004-11-04 15:49               ` Daniel Jacobowitz
  0 siblings, 0 replies; 15+ messages in thread
From: Daniel Jacobowitz @ 2004-11-04 15:49 UTC (permalink / raw)
  To: paul, binutils, rearnsha

On Thu, Nov 04, 2004 at 10:42:31AM -0500, Ian Lance Taylor wrote:
> Daniel Jacobowitz <drow@false.org> writes:
> 
> > > That said, I'm building Thumb shared libraries in which the PLT takes
> > > up 120K, or some 4.5% of the text section size.  It's probably
> > > possible to use version scripts to force some of the symbols to be
> > > local, but this source code is neither from us nor from our customer,
> > > so that is not a simple task.  Using Thumb instructions in the PLT
> > > would give me some clearly measurable size improvements.
> > 
> > Would it really?  Here's an alternative: in the patches I'll be
> > posting, I add support for independently sized PLT entries.  It would
> > then be relatively simple (not trivial, because of relaxation problems,
> > but doable) to use a two instruction ARM PLT sequence if it is in
> > range.  The largest shared library I have handy at the moment has an
> > 85K PLT using the new three-word entries, and the first word is
> > _always_ redundant.  Then use interworking branches to get to the PLT.
> > 
> > I doubt you'll get a Thumb PLT sequence under eight bytes.
> 
> I don't know what the three-word PLT entry is.

Take a look at the PLT entries produced by any recent version of the
linker (I don't know whether it was in 2.15 or not; if not it went in
soon after).  Phil contributed a three-word PLT sequence that looks
like:
  add ip, pc, #OFF1
  add ip, ip, #OFF2
  ldr pc, [ip, #OFF3]!

>  By relaxation, do you
> mean loading a GOT index into a register and then branching to the
> symbol resolution routine?  That would work for the first 256 GOT
> entries, and for some subset of the subsequent ones.  Or did you have
> something else in mind?

In the above sequence, OFF1 is almost always 0 unless your shared
library is pretty large.  It looks like OFF2 and OFF3 give you a range
of 20 bits.  Given that the PLT is placed at the beginning of the text
section, that's pretty limiting; I imagine it could be placed at the
end instead - I'm not sure why it is the usual convention to put it at
the beginning, there may be some reason I am missing.

-- 
Daniel Jacobowitz

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

* Re: [arm] EABI annotation of thumb symbols.
  2004-11-04 15:47           ` Richard Earnshaw
@ 2004-11-04 16:01             ` Ian Lance Taylor
  0 siblings, 0 replies; 15+ messages in thread
From: Ian Lance Taylor @ 2004-11-04 16:01 UTC (permalink / raw)
  To: Richard Earnshaw; +Cc: Daniel Jacobowitz, Paul Brook, binutils

Richard Earnshaw <rearnsha@arm.com> writes:

> Ultimately it depends on the performance you want out of your code.  If
> performance is not a goal at all, then you could probably squeeze each
> PLT stub down to about 4 bytes, with
> 
> 	mov	ip, pc
> 	b	common_plt
> 
> (and if the plt cannot reach common_plt, then chain it to one that
> can).  common_plt can do all manner of things, provided that at the
> point at which it calls into the target function things are set up
> correctly in case we end up in the dynamic linker.  But remember that
> the sequence above depends critically on each PLT sequence being the
> same length and on them all being located sequentially in memory (so
> that the PC value can be converted algorithmically into a PLTGOT value).

Omitting the offset word from each entry is a good idea.  Thanks.
Unfortunately even trickier to implement when the PLT is larger than
4096 bytes.

Ian

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

end of thread, other threads:[~2004-11-04 16:01 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-02 14:22 [arm] EABI annotation of thumb symbols Paul Brook
2004-11-02 14:41 ` Richard Earnshaw
2004-11-02 15:12   ` Daniel Jacobowitz
2004-11-04  1:55     ` Ian Lance Taylor
2004-11-04 10:20       ` Richard Earnshaw
2004-11-04 14:19         ` Daniel Jacobowitz
2004-11-04 14:33           ` Richard Earnshaw
2004-11-04 15:10             ` Daniel Jacobowitz
2004-11-04 15:03         ` Ian Lance Taylor
2004-11-04 15:08           ` Daniel Jacobowitz
2004-11-04 15:42             ` Ian Lance Taylor
2004-11-04 15:49               ` Daniel Jacobowitz
2004-11-04 15:47           ` Richard Earnshaw
2004-11-04 16:01             ` Ian Lance Taylor
2004-11-02 15:06 ` Ian Lance Taylor

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