aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2009-04-30 15:47:13 +0000
committerNick Clifton <nickc@redhat.com>2009-04-30 15:47:13 +0000
commitd8045f234d8865a7a7bfce71e81fcbeaf4098a7e (patch)
tree31e6bc2d28ac295c02dde51ed85fc561675e29a6 /gas
parentb22a5a41858f1962abba75900ef9928efca36bcd (diff)
downloadgdb-d8045f234d8865a7a7bfce71e81fcbeaf4098a7e.zip
gdb-d8045f234d8865a7a7bfce71e81fcbeaf4098a7e.tar.gz
gdb-d8045f234d8865a7a7bfce71e81fcbeaf4098a7e.tar.bz2
include/elf
2009-04-30 Nick Clifton <nickc@redhat.com> * common.h (STT_GNU_IFUNC): Define. elfcpp 2009-04-30 Nick Clifton <nickc@redhat.com> * (enum STT): Add STT_GNU_IFUNC. gas 2009-04-30 Nick Clifton <nickc@redhat.com> * config/obj-elf.c (obj_elf_type): Add support for a gnu_indirect_function type. * config/tc-i386.c (tc_i386_fix_adjustable): Do not adjust fixups against indirect function symbols. * doc/as.texinfo (.type): Document the support for the gnu_indirect_function symbol type. * NEWS: Mention the new feature. gas/testsuite 2009-04-30 Nick Clifton <nickc@redhat.com> * gas/elf/elf.exp: Extend type test to include an ifunc symbol. Provide an alternative test for targets which do not support ifunc symbols. (type.s): Add entry for an ifunc symbol. (type.e): Add ifunc entry to expected symbol dump. (section2.e-armelf): Add entry for ifunc symbol. (type-noifunc.s): New file. (type-noifunc.e): New file. bfd/ 2009-04-30 Nick Clifton <nickc@redhat.com> * elf-bfd.h (struct bfd_elf_section_data): Add indirect_relocs section pointer. (struct elf_obj_data): Add has_ifunc_symbols boolean. * elf.c (swap_out_syms): Convert BSF_GNU_INDIRECT_FUNCTION flags into a STT_GNU_IFUNC symbol type. (_bfd_elf_is_function_type): Accept STT_GNU_IFUNC as a function type. (_bfd_elf_set_osabi): Set the osasbi field to ELFOSABI_LINUX if the binary contains ifunc symbols. * elfcode.h (elf_slurp_symbol_table): Translate the STT_GNU_IFUNC symbol type into a BSF_GNU_INDIRECT_FUNCTION flag. * elf32-i386.c (is_indirect_function): New function. (elf_i386_check_relocs): Create an ifunc output section. (allocate_dynrelocs): Create dynamic relocs in the ifunc output section if necessary. (elf_i386_relocate_section): Emit a reloc against an ifunc symbol if necessary. (elf_i386_add_symbol_hook): New function. Set the has_ifunc_symbols field of the elf_obj_data structure if an ifunc symbol is encountered. (elf_backend_post_process_headers): Define. (elf_backend_add_symbol_hook): Define. (elf_i386_post_process_headers): Rename to elf_i388_fbsd_post_process_headers. * elf64-x86_64.c (IS_X86_64_PCREL_TYPE): New macro. (is_indirect_function): New function. (elf64_x86_64_check_relocs): Create an ifunc output section. (allocate_dynrelocs): Create dynamic relocs in the ifunc output section if necessary. (elf64_x86_64_relocate_section): Emit a reloc against an ifunc symbol if necessary. (elf_i386_add_symbol_hook): Set the has_ifunc_symbols field of the elf_obj_data structure if an ifunc symbol is encountered. (elf_backend_post_process_headers): Define. * elflink.c (_bfd_elf_adjust_dynamic_symbol): Always create a PLT if we have ifunc symbols to handle. (get_ifunc_reloc_section_name): New function. Computes the name for an ifunc section. (_bfd_elf_make_ifunc_reloc_section): New function. Creates a section to hold ifunc relocs. * syms.c (BSF_GNU_INDIRECT_FUNCTION): Define. (bfd_print_symbol_vandf): Handle ifunc symbols. (bfd_decode_symclass): Likewise. * bfd-in2.h: Regenerate. binutils 2009-04-30 Nick Clifton <nickc@redhat.com> * readelf.c (dump_relocations): Display a relocation against an ifunc symbol as if it were a function invocation. (get_symbol_type): Handle STT_GNU_IFUNC. ld 2009-04-30 Nick Clifton <nickc@redhat.com> * NEWS: Mention support for IFUNC symbols. ld/testsuite 2009-04-30 Nick Clifton <nickc@redhat.com> * ld-ifunc: New directory. * ld-ifunc/ifunc.exp: New file: Run the IFUNC tests. * ld-ifunc/prog.c: New file. * ld-ifunc/lib.c: New file.
Diffstat (limited to 'gas')
-rw-r--r--gas/ChangeLog10
-rw-r--r--gas/NEWS5
-rw-r--r--gas/config/obj-elf.c14
-rw-r--r--gas/config/tc-i386.c4
-rw-r--r--gas/doc/as.texinfo5
-rw-r--r--gas/testsuite/gas/elf/elf.exp16
-rw-r--r--gas/testsuite/gas/elf/section2.e-armelf3
-rw-r--r--gas/testsuite/gas/elf/type-noifunc.e5
-rw-r--r--gas/testsuite/gas/elf/type-noifunc.s20
-rw-r--r--gas/testsuite/gas/elf/type.e3
-rw-r--r--gas/testsuite/gas/elf/type.s4
11 files changed, 85 insertions, 4 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index ca81227..ade42dd 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,13 @@
+2009-04-30 Nick Clifton <nickc@redhat.com>
+
+ * config/obj-elf.c (obj_elf_type): Add support for a
+ gnu_indirect_function type.
+ * config/tc-i386.c (tc_i386_fix_adjustable): Do not adjust fixups
+ against indirect function symbols.
+ * doc/as.texinfo (.type): Document the support for the
+ gnu_indirect_function symbol type.
+ * NEWS: Mention the new feature.
+
2009-04-24 Cary Coutant <ccoutant@google.com>
* NEWS: Add item about discriminator support.
diff --git a/gas/NEWS b/gas/NEWS
index e94438f..0650b30 100644
--- a/gas/NEWS
+++ b/gas/NEWS
@@ -5,6 +5,11 @@
* Add support for Sunplus score architecture.
+* The .type pseudo-op now accepts a type of STT_GNU_IFUNC which can be used to
+ indicate that if the symbol is the target of a relocation, its value should
+ not be use. Instead the function should be invoked and its result used as
+ the value.
+
* Add support for Lattice Mico32 (lm32) architecture.
Changes in 2.19:
diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c
index 4c68779..3d80ecc 100644
--- a/gas/config/obj-elf.c
+++ b/gas/config/obj-elf.c
@@ -1664,6 +1664,20 @@ obj_elf_type (int ignore ATTRIBUTE_UNUSED)
}
}
}
+ else if (strcmp (typename, "gnu_indirect_function") == 0
+ || strcmp (typename, "10") == 0
+ || strcmp (typename, "STT_GNU_IFUNC") == 0)
+ {
+ const struct elf_backend_data *bed;
+
+ bed = get_elf_backend_data (stdoutput);
+ if (!(bed->elf_osabi == ELFOSABI_LINUX
+ /* GNU/Linux is still using the default value 0. */
+ || bed->elf_osabi == ELFOSABI_NONE))
+ as_bad (_("symbol type \"%s\" is supported only by GNU targets"),
+ typename);
+ type = BSF_FUNCTION | BSF_GNU_INDIRECT_FUNCTION;
+ }
#ifdef md_elf_symbol_type
else if ((type = md_elf_symbol_type (typename, sym, elfsym)) != -1)
;
diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index 767d1fc..dd2adcc 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -2499,6 +2499,10 @@ tc_i386_fix_adjustable (fixS *fixP ATTRIBUTE_UNUSED)
|| fixP->fx_r_type == BFD_RELOC_VTABLE_INHERIT
|| fixP->fx_r_type == BFD_RELOC_VTABLE_ENTRY)
return 0;
+
+ if (fixP->fx_addsy != NULL
+ && symbol_get_bfdsym (fixP->fx_addsy)->flags & BSF_GNU_INDIRECT_FUNCTION)
+ return 0;
#endif
return 1;
}
diff --git a/gas/doc/as.texinfo b/gas/doc/as.texinfo
index 682b368..0968a29 100644
--- a/gas/doc/as.texinfo
+++ b/gas/doc/as.texinfo
@@ -6327,6 +6327,11 @@ The types supported are:
@itemx function
Mark the symbol as being a function name.
+@item STT_GNU_IFUNC
+@itemx gnu_indirect_function
+Mark the symbol as an indirect function when evaluated during reloc
+processing. (This is only supported on Linux targeted assemblers).
+
@item STT_OBJECT
@itemx object
Mark the symbol as being a data object.
diff --git a/gas/testsuite/gas/elf/elf.exp b/gas/testsuite/gas/elf/elf.exp
index 1085b04..abf2030 100644
--- a/gas/testsuite/gas/elf/elf.exp
+++ b/gas/testsuite/gas/elf/elf.exp
@@ -114,8 +114,20 @@ if { ([istarget "*-*-*elf*"]
run_elf_list_test "section5" "" "-al" "-SW" "| grep \" \\\\.test\\\[0-9\\\]\""
run_dump_test "struct"
run_dump_test "symtab"
- run_dump_test "symver"
- run_elf_list_test "type" "" "" "-s" "| grep \"1 \\\[FIONTC\\\]\""
+ run_dump_test "symver"
+
+ # The MSP port sets the ELF header's OSABI field to ELFOSABI_STANDALONE.
+ # The non-eabi ARM ports sets it to ELFOSABI_ARM.
+ # So for these targets we cannot include an IFUNC symbol type
+ # in the symbol type test.
+ if { [istarget "msp*-*-*"]
+ || [istarget "arm*-*-*"]
+ || [istarget "xscale*-*-*"]} then {
+ run_elf_list_test "type-noifunc" "" "" "-s" "| grep \"1 \\\[FONTC\\\]\""
+ } else {
+ run_elf_list_test "type" "" "" "-s" "| grep \"1 \\\[FIONTC\\\]\""
+ }
+
run_dump_test "section6"
run_dump_test "section7"
}
diff --git a/gas/testsuite/gas/elf/section2.e-armelf b/gas/testsuite/gas/elf/section2.e-armelf
index 8d2e4ff..44ecffc 100644
--- a/gas/testsuite/gas/elf/section2.e-armelf
+++ b/gas/testsuite/gas/elf/section2.e-armelf
@@ -1,5 +1,5 @@
-Symbol table '.symtab' contains 6 entries:
+Symbol table '.symtab' contains 7 entries:
Num: Value[ ]* Size Type Bind Vis Ndx Name
0: 0+0 0 NOTYPE LOCAL DEFAULT UND
1: 0+0 0 SECTION LOCAL DEFAULT 1
@@ -7,3 +7,4 @@ Symbol table '.symtab' contains 6 entries:
3: 0+0 0 SECTION LOCAL DEFAULT 3
4: 0+0 0 SECTION LOCAL DEFAULT 4
5: 0+0 0 NOTYPE LOCAL DEFAULT 4 \$d
+ 6: 0+0 0 SECTION LOCAL DEFAULT 5
diff --git a/gas/testsuite/gas/elf/type-noifunc.e b/gas/testsuite/gas/elf/type-noifunc.e
new file mode 100644
index 0000000..81ee39b
--- /dev/null
+++ b/gas/testsuite/gas/elf/type-noifunc.e
@@ -0,0 +1,5 @@
+ .: 0+0 1 FUNC LOCAL DEFAULT . function
+ .: 0+0 1 OBJECT LOCAL DEFAULT . object
+ .: 0+1 1 TLS LOCAL DEFAULT . tls_object
+ ..: 0+2 1 NOTYPE LOCAL DEFAULT . notype
+ ..: 0+1 1 (COMMON|OBJECT) GLOBAL DEFAULT COM common
diff --git a/gas/testsuite/gas/elf/type-noifunc.s b/gas/testsuite/gas/elf/type-noifunc.s
new file mode 100644
index 0000000..11f75bf
--- /dev/null
+++ b/gas/testsuite/gas/elf/type-noifunc.s
@@ -0,0 +1,20 @@
+ .text
+ .size function,1
+ .type function,%function
+function:
+ .byte 0x0
+ .data
+ .type object,%object
+ .size object,1
+object:
+ .byte 0x0
+ .type tls_object,%tls_object
+ .size tls_object,1
+tls_object:
+ .byte 0x0
+ .type notype,%notype
+ .size notype,1
+notype:
+ .byte 0x0
+ .comm common, 1
+ .type common,STT_COMMON
diff --git a/gas/testsuite/gas/elf/type.e b/gas/testsuite/gas/elf/type.e
index 50a49ab..95d846a 100644
--- a/gas/testsuite/gas/elf/type.e
+++ b/gas/testsuite/gas/elf/type.e
@@ -1,5 +1,6 @@
.: 0+0 1 FUNC LOCAL DEFAULT . function
+ .: 0+1 1 IFUNC LOCAL DEFAULT . indirect_function
.: 0+0 1 OBJECT LOCAL DEFAULT . object
.: 0+1 1 TLS LOCAL DEFAULT . tls_object
- .: 0+2 1 NOTYPE LOCAL DEFAULT . notype
+ ..: 0+2 1 NOTYPE LOCAL DEFAULT . notype
..: 0+1 1 (COMMON|OBJECT) GLOBAL DEFAULT COM common
diff --git a/gas/testsuite/gas/elf/type.s b/gas/testsuite/gas/elf/type.s
index 11f75bf..8620cc2 100644
--- a/gas/testsuite/gas/elf/type.s
+++ b/gas/testsuite/gas/elf/type.s
@@ -3,6 +3,10 @@
.type function,%function
function:
.byte 0x0
+ .size indirect_function,1
+ .type indirect_function,%gnu_indirect_function
+indirect_function:
+ .byte 0x0
.data
.type object,%object
.size object,1