A small cleanup. 'struct lwp_info'::thread_known is only useful for
thread-db.c.
gdbserver/
2013-04-16 Pedro Alves <palves@redhat.com>
* linux-low.h (struct lwp_info) <thread_known>: Move under
the USE_THREAD_DB #ifdef.
The previous patches are still not sufficient to build gdbserver with
our copy of thread_db.h.
../../../src/gdb/gdbserver/thread-db.c: In function ‘find_one_thread’:
../../../src/gdb/gdbserver/thread-db.c:316:6: error: ‘struct lwp_info’ has no member named ‘th’
../../../src/gdb/gdbserver/thread-db.c: In function ‘attach_thread’:
../../../src/gdb/gdbserver/thread-db.c:341:6: error: ‘struct lwp_info’ has no member named ‘th’
../../../src/gdb/gdbserver/thread-db.c: In function ‘thread_db_get_tls_address’:
../../../src/gdb/gdbserver/thread-db.c:514:47: error: ‘struct lwp_info’ has no member named ‘th’
make: *** [thread-db.o] Error 1
First, linux-low.h is including <thread_db.h> directly instead of our
gdb_thread_db.h, although thread-db.c includes the latter. Then the
'th' field of struct lwp_info is only defined if HAVE_THREAD_DB_H is
defined, which is not true if we're using our replacement copy of
thread_db.h. We have a USE_THREAD_DB symbol defined if we're building
thread-db.c that's ideal for this, however, it's currently only
defined when compiling linux-low.c (through a Makefile rule). The
patch makes it defined when compiling any file.
gdb/gdbserver/
2013-04-16 Pedro Alves <palves@redhat.com>
* Makefile.in (INTERNAL_CFLAGS): Add @USE_THREAD_DB@.
(linux-low.o): Delete rule.
* linux-low.h: Always include "gdb_thread_db.h" instead of
conditionally including thread_db.h.
(struct lwp_info) <th>: Guard with #ifdef USE_THREAD_DB instead of
HAVE_THREAD_DB_H.
As glibc_thread_db.h is a 3rd party imported file, we should not
update its copyright year range in the new year process.
gdb/
2013-04-16 Pedro Alves <palves@redhat.com>
* copyright.py (EXCLUDE_LIST): Add gdb/common/glibc_thread_db.h.
Attempting to build gdbserver with our copy of thread_db.h yields:
In file included from ../../../src/gdb/gdbserver/../common/gdb_thread_db.h:4:0,
from ../../../src/gdb/gdbserver/thread-db.c:30:
../../../src/gdb/gdbserver/../common/glibc_thread_db.h:108:3: error: unknown type name ‘uint32_t’
In file included from ../../../src/gdb/gdbserver/../common/gdb_thread_db.h:4:0,
from ../../../src/gdb/gdbserver/thread-db.c:30:
../../../src/gdb/gdbserver/../common/glibc_thread_db.h:199:5: error: unknown type name ‘uintptr_t’
../../../src/gdb/gdbserver/../common/glibc_thread_db.h:269:3: error: unknown type name ‘intptr_t’
../../../src/gdb/gdbserver/../common/glibc_thread_db.h:270:3: error: unknown type name ‘intptr_t’
We used to have a workaround for this, but the patch to import
gnulib's stdint.h removed it:
http://www.sourceware.org/ml/gdb-patches/2008-06/msg00050.html
and defs.h made to always include stdint.h. However, gdbserver
doesn't include stdint.h in its equivalent server.h.
Rather than working around the issue, I've imported a more recent
version from glibc, which itself includes <stdint.h>. Other than
copyright years and FSF snail mail address, the file hasn't been
touched since 2003 in glibc. AFAICS, our version was updated last in
2000-09-03.
A note on the apparent license change: before the previous patch, this
file's contents were part of gdb_thread_db.h, and we can see that its
license's text was changed in this patch
<http://sourceware.org/ml/gdb-patches/2009-03/msg00251.html>. That
was certainly just an easy to overlook grep/sed mistake that fell
through the cracks.
gdb/common/
2013-04-16 Pedro Alves <palves@redhat.com>
* glibc_thread_db.h: Update from upstream glibc
(git 568035b7874a099087b77f7bba3e36a1173787b0).
Having this on a separate file makes it easier to import a new version
-- one can just copy over instead of having to care about preserving
the GDB-specific bits.
2013-04-16 Pedro Alves <palves@redhat.com>
* common/gdb_thread_db.h [!HAVE_THREAD_DB_H]: Factor out to ...
* common/glibc_thread_db.h: ... this new file ...
* common/gdb_thread_db.h [!HAVE_THREAD_DB_H]: ... and include it.
This patch:
http://sourceware.org/ml/gdb-patches/2009-04/msg00115.html
Changed behaviour by only defining LIBTHREAD_DB_SO if thread_db.h exists. The
definition of LIBTHREAD_DB_SO and LIBTHREAD_DB_SEARCH_PATH should be moved
outside of #ifdef HAVE_THREAD_DB_H.
This is based on a patch attached to the PR, however, it needed a
tweak, as it was it broke the HAVE_THREAD_DB_H path.
2013-04-16 Will Newton <will.newton@gmail.com>
Pedro Alves <palves@redhat.com>
PR build/11881
* common/gdb_thread_db.h (LIBTHREAD_DB_SO)
(LIBTHREAD_DB_SEARCH_PATH): Move outside of #ifdef
HAVE_THREAD_DB_H.
Mention "set foo unlimited" in NEWS, right below the "New options"
section.
2013-04-16 Pedro Alves <palves@redhat.com>
Eli Zaretskii <eliz@gnu.org>
* NEWS: Mention "set foo unlimited".
(struct create_dwo_cu_data): Renamed from create_dwo_info_table_data.
(create_dwo_cu_reader): Renamed from
create_dwo_debug_info_hash_table_reader.
(create_dwo_cu): Renamed from create_dwo_debug_info_hash_table.
Remove support for multiple CUs in a DWO file.
(open_and_init_dwo_file, lookup_dwo_cutu): Update.
non_got_ref may not be set when building shared library. We need to set
non_got_ref if there are any non-PIC relocations. But we only did this
when there were no PLT/GOT relocations. It failed when there is a PLT
relocation. This checkin moves the non_got_ref check out.
bfd/
2013-04-15 H.J. Lu <hongjiu.lu@intel.com>
PR ld/15371
* elf-ifunc.c (_bfd_elf_allocate_ifunc_dyn_relocs): Check
regular reference without non-GOT reference when building
shared library.
ld/testsuite/
2013-04-15 H.J. Lu <hongjiu.lu@intel.com>
PR ld/15371
* ld-ifunc/ifunc-20-i386.d: New file.
* ld-ifunc/ifunc-20-x86-64.d: Likewise.
* ld-ifunc/ifunc-20.s: Likewise.
diff --git a/bfd/elf-ifunc.c b/bfd/elf-ifunc.c
index e56427d..7e7ec36 100644
--- a/bfd/elf-ifunc.c
+++ b/bfd/elf-ifunc.c
@@ -187,23 +187,20 @@ _bfd_elf_allocate_ifunc_dyn_relocs (struct bfd_link_info *info,
htab = elf_hash_table (info);
+ /* When building shared library, we need to handle the case where it is
+ marked with regular reference, but not non-GOT reference since the
+ non-GOT reference bit may not be set here. */
+ if (info->shared && !h->non_got_ref && h->ref_regular)
+ for (p = *head; p != NULL; p = p->next)
+ if (p->count)
+ {
+ h->non_got_ref = 1;
+ goto keep;
+ }
+
/* Support garbage collection against STT_GNU_IFUNC symbols. */
if (h->plt.refcount <= 0 && h->got.refcount <= 0)
{
- /* When building shared library, we need to handle the case
- where it is marked with regular reference, but not non-GOT
- reference. It may happen if we didn't see STT_GNU_IFUNC
- symbol at the time when checking relocations. */
- if (info->shared
- && !h->non_got_ref
- && h->ref_regular)
- for (p = *head; p != NULL; p = p->next)
- if (p->count)
- {
- h->non_got_ref = 1;
- goto keep;
- }
-
h->got = htab->init_got_offset;
h->plt = htab->init_plt_offset;
*head = NULL;
diff --git a/ld/testsuite/ld-ifunc/ifunc-20-i386.d b/ld/testsuite/ld-ifunc/ifunc-20-i386.d
new file mode 100644
index 0000000..9373fcf
--- /dev/null
+++ b/ld/testsuite/ld-ifunc/ifunc-20-i386.d
@@ -0,0 +1,13 @@
+#source: ifunc-20.s
+#ld: -shared -m elf_i386 -z nocombreloc
+#as: --32
+#readelf: -r --wide
+#target: x86_64-*-* i?86-*-*
+
+Relocation section '.rel.ifunc' at offset 0x[0-9a-f]+ contains 1 entries:
+[ ]+Offset[ ]+Info[ ]+Type[ ]+.*
+[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_386_32[ ]+ifunc\(\)[ ]+ifunc
+
+Relocation section '.rel.plt' at offset 0x[0-9a-f]+ contains 1 entries:
+[ ]+Offset[ ]+Info[ ]+Type[ ]+.*
+[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_386_JUMP_SLOT[ ]+ifunc\(\)[ ]+ifunc
diff --git a/ld/testsuite/ld-ifunc/ifunc-20-x86-64.d b/ld/testsuite/ld-ifunc/ifunc-20-x86-64.d
new file mode 100644
index 0000000..39492d4
--- /dev/null
+++ b/ld/testsuite/ld-ifunc/ifunc-20-x86-64.d
@@ -0,0 +1,13 @@
+#source: ifunc-20.s
+#ld: -shared -m elf_x86_64 -z nocombreloc
+#as: --64
+#readelf: -r --wide
+#target: x86_64-*-*
+
+Relocation section '.rela.ifunc' at offset 0x[0-9a-f]+ contains 1 entries:
+[ ]+Offset[ ]+Info[ ]+Type[ ]+.*
+[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_X86_64_64[ ]+ifunc\(\)[ ]+ifunc \+ 0
+
+Relocation section '.rela.plt' at offset 0x[0-9a-f]+ contains 1 entries:
+[ ]+Offset[ ]+Info[ ]+Type[ ]+.*
+[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_X86_64_JUMP_SLOT[ ]+ifunc\(\)[ ]+ifunc \+ 0
diff --git a/ld/testsuite/ld-ifunc/ifunc-20.s b/ld/testsuite/ld-ifunc/ifunc-20.s
new file mode 100644
index 0000000..9d45455
--- /dev/null
+++ b/ld/testsuite/ld-ifunc/ifunc-20.s
@@ -0,0 +1,16 @@
+ .section .data.rel,"aw",@progbits
+ .globl ifunc_ptrt
+ .type ifunc_ptr, @object
+ifunc_ptr:
+ .dc.a ifunc
+ .text
+ .type ifunc, @gnu_indirect_function
+ .globl ifunc
+ifunc:
+ ret
+ .size ifunc, .-ifunc
+ .type bar, @function
+ .globl bar
+bar:
+ call ifunc@PLT
+ .size bar, .-bar
Add option to link testcases with Pthreads library when
using 'prepare_for_testing' in tests.
testsuite/
* lib/gdb.exp (build_executable_from_specs): Use
gdb_compile_pthreads to compile if option "pthreads" is
specified.
* c-lang.c (cplus_language_defn): Use gdb_demangle.
* c-typeprint.c (c_type_print_base): Use gdb_demangle.
* cp-support.c (mangled_name_to_comp): Use gdb_demangle.
(gdb_demangle): New function.
* cp-support.h (gdb_demangle): Declare.
* dwarf2read.c (dwarf2_physname, fixup_partial_die)
(dwarf2_name): Use gdb_demangle.
* gdbtypes.c (check_stub_method): Use gdb_demangle.
* gnu-v3-abi.c (gnuv3_rtti_type): Strip @plt and version
suffixes from name.
(gnuv3_print_method_ptr): Use gdb_demangle.
* jv-lang.c (java_demangle): Use gdb_demangle.
* jv-typeprint.c (java_type_print_base): Use gdb_demangle.
* language.c (unk_lang_demangle): Use gdb_demangle.
* symtab.c (symbol_find_demangled_name)
(demangle_for_lookup): Use gdb_demangle.
* ctf.c (_initialize_ctf): Include "completer.h".
Call add_target_with_completer instead of add_target.
gdb/testsuite/
* gdb.base/completion.exp: Test completion of command
'target ctf' if target ctf is supported.
owner when sections are not adjacent and exceed group size.
(Target_powerpc::group_sections): Handle corner case.
(Target_powerpc::Branch_info::make_stub): Handle case where
stub table doesn't exist due to branches in non-exec sections.
(Target_powerpc::Relocate::relocate): Likewise.