* gold patch committed: Warn about _32 and _PC32 in shared object
@ 2010-12-15 15:43 Ian Lance Taylor
0 siblings, 0 replies; only message in thread
From: Ian Lance Taylor @ 2010-12-15 15:43 UTC (permalink / raw)
To: binutils
[-- Attachment #1: Type: text/plain, Size: 700 bytes --]
PR 12324 points out that gold does not issue the same warnings as GNU ld
when it comes to putting non-PIC relocations in shared objects. When I
added the warning, I looked at the list of relocations that glibc
supports, but I didn't consider that two of them can overflow at
runtime. This patch warns about those two. I had to adjust a test case
to compile with -fpic. Committed to mainline.
Ian
2010-12-15 Ian Lance Taylor <iant@google.com>
PR gold/12324
* x86_64.cc (Target_x86_64::Scan::check_non_pic): Give an error
for R_X86_64_32 and R_X86_64_PC32.
* testsuite/Makefile.am (ver_matching_def.so): Depend on and use
ver_matching_def_pic.o.
(ver_matching_def_pic.o): New target.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: warn --]
[-- Type: text/x-diff, Size: 2468 bytes --]
Index: x86_64.cc
===================================================================
RCS file: /cvs/src/src/gold/x86_64.cc,v
retrieving revision 1.120
diff -p -u -r1.120 x86_64.cc
--- x86_64.cc 14 Dec 2010 19:03:30 -0000 1.120
+++ x86_64.cc 15 Dec 2010 15:33:35 -0000
@@ -1329,7 +1329,8 @@ Target_x86_64::Scan::check_non_pic(Relob
{
switch (r_type)
{
- // These are the relocation types supported by glibc for x86_64.
+ // These are the relocation types supported by glibc for x86_64
+ // which should always work.
case elfcpp::R_X86_64_RELATIVE:
case elfcpp::R_X86_64_IRELATIVE:
case elfcpp::R_X86_64_GLOB_DAT:
@@ -1338,9 +1339,18 @@ Target_x86_64::Scan::check_non_pic(Relob
case elfcpp::R_X86_64_DTPOFF64:
case elfcpp::R_X86_64_TPOFF64:
case elfcpp::R_X86_64_64:
+ case elfcpp::R_X86_64_COPY:
+ return;
+
+ // glibc supports these reloc types, but they can overflow.
case elfcpp::R_X86_64_32:
case elfcpp::R_X86_64_PC32:
- case elfcpp::R_X86_64_COPY:
+ if (this->issued_non_pic_error_)
+ return;
+ gold_assert(parameters->options().output_is_position_independent());
+ object->error(_("requires dynamic reloc which may overflow at runtime; "
+ "recompile with -fPIC"));
+ this->issued_non_pic_error_ = true;
return;
default:
Index: testsuite/Makefile.am
===================================================================
RCS file: /cvs/src/src/gold/testsuite/Makefile.am,v
retrieving revision 1.152
diff -p -u -r1.152 Makefile.am
--- testsuite/Makefile.am 29 Oct 2010 15:45:40 -0000 1.152
+++ testsuite/Makefile.am 15 Dec 2010 15:33:35 -0000
@@ -1146,8 +1146,10 @@ binary.txt: $(srcdir)/binary.in
check_SCRIPTS += ver_matching_test.sh
check_DATA += ver_matching_test.stdout
MOSTLYCLEANFILES += ver_matching_test.stdout
-ver_matching_def.so: ver_matching_def.cc $(srcdir)/version_script.map gcctestdir/ld
- $(CXXLINK) -O0 -Bgcctestdir/ -shared $(srcdir)/ver_matching_def.cc -Wl,--version-script=$(srcdir)/version_script.map
+ver_matching_def.so: ver_matching_def_pic.o $(srcdir)/version_script.map gcctestdir/ld
+ $(CXXLINK) -O0 -Bgcctestdir/ -shared ver_matching_def_pic.o -Wl,--version-script=$(srcdir)/version_script.map
+ver_matching_def_pic.o: ver_matching_def.cc
+ $(CXXCOMPILE) -O0 -c -fpic -o $@ $<
ver_matching_test.stdout: ver_matching_def.so
$(TEST_OBJDUMP) -T ver_matching_def.so | $(TEST_CXXFILT) > ver_matching_test.stdout
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2010-12-15 15:37 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-15 15:43 gold patch committed: Warn about _32 and _PC32 in shared object 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).