This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
gold patch committed: Better handling of orphan TLS sections
- From: Ian Lance Taylor <iant at google dot com>
- To: binutils at sourceware dot org
- Date: Tue, 23 Mar 2010 14:06:52 -0700
- Subject: gold patch committed: Better handling of orphan TLS sections
I committed this patch to gold to improve the handling of orphan TLS
sections, so that they at least have a fighting chance of working
correctly.
Ian
2010-03-23 Ian Lance Taylor <iant@google.com>
* script-sections.cc (class Orphan_section_placement): Define
PLACE_TLS and PLACE_TLS_BSS.
(Orphan_section_placement::Orphan_section_placement): Initialize
new places.
(Orphan_section_placement::find_place): Handle SHF_TLS sections.
* testsuite/Makefile.am (check_PROGRAMS): Add tls_script_test.
(tls_script_test_SOURCES): Define.
(tls_script_test_DEPENDENCIES): Define.
(tls_script_test_LDFLAGS): Define.
(tls_script_test_LDADD): Define.
* testsuite/Makefile.in: Rebuild.
Index: script-sections.cc
===================================================================
RCS file: /cvs/src/src/gold/script-sections.cc,v
retrieving revision 1.30
diff -p -u -r1.30 script-sections.cc
--- script-sections.cc 23 Jan 2010 01:07:59 -0000 1.30
+++ script-sections.cc 23 Mar 2010 20:52:57 -0000
@@ -85,6 +85,8 @@ class Orphan_section_placement
PLACE_TEXT,
PLACE_RODATA,
PLACE_DATA,
+ PLACE_TLS,
+ PLACE_TLS_BSS,
PLACE_BSS,
PLACE_REL,
PLACE_INTERP,
@@ -122,6 +124,8 @@ Orphan_section_placement::Orphan_section
this->initialize_place(PLACE_TEXT, ".text");
this->initialize_place(PLACE_RODATA, ".rodata");
this->initialize_place(PLACE_DATA, ".data");
+ this->initialize_place(PLACE_TLS, NULL);
+ this->initialize_place(PLACE_TLS_BSS, NULL);
this->initialize_place(PLACE_BSS, ".bss");
this->initialize_place(PLACE_REL, NULL);
this->initialize_place(PLACE_INTERP, ".interp");
@@ -232,6 +236,13 @@ Orphan_section_placement::find_place(Out
index = PLACE_LAST;
else if (type == elfcpp::SHT_NOTE)
index = PLACE_INTERP;
+ else if ((flags & elfcpp::SHF_TLS) != 0)
+ {
+ if (type == elfcpp::SHT_NOBITS)
+ index = PLACE_TLS_BSS;
+ else
+ index = PLACE_TLS;
+ }
else if (type == elfcpp::SHT_NOBITS)
index = PLACE_BSS;
else if ((flags & elfcpp::SHF_WRITE) != 0)
@@ -265,6 +276,14 @@ Orphan_section_placement::find_place(Out
case PLACE_INTERP:
follow = PLACE_TEXT;
break;
+ case PLACE_TLS:
+ follow = PLACE_DATA;
+ break;
+ case PLACE_TLS_BSS:
+ follow = PLACE_TLS;
+ if (!this->places_[PLACE_TLS].have_location)
+ follow = PLACE_DATA;
+ break;
}
if (follow != PLACE_MAX && this->places_[follow].have_location)
{
@@ -2300,7 +2319,7 @@ Orphan_output_section::set_section_addre
uint64_t addralign;
uint64_t size;
- // We know what are single-threaded, so it is OK to lock the
+ // We know we are single-threaded, so it is OK to lock the
// object.
{
const Task* task = reinterpret_cast<const Task*>(-1);
Index: testsuite/Makefile.am
===================================================================
RCS file: /cvs/src/src/gold/testsuite/Makefile.am,v
retrieving revision 1.126
diff -p -u -r1.126 Makefile.am
--- testsuite/Makefile.am 22 Mar 2010 22:48:05 -0000 1.126
+++ testsuite/Makefile.am 23 Mar 2010 20:52:57 -0000
@@ -1094,6 +1094,12 @@ script_test_4: basic_test.o gcctestdir/l
script_test_4.stdout: script_test_4
$(TEST_READELF) -SlW script_test_4 > script_test_4.stdout
+check_PROGRAMS += tls_script_test
+tls_script_test_SOURCES = $(tls_test_SOURCES)
+tls_script_test_DEPENDENCIES = $(tls_test_DEPENDENCIES) $(srcdir)/script_test_4.t
+tls_script_test_LDFLAGS = $(tls_test_LDFLAGS) -T $(srcdir)/script_test_4.t
+tls_script_test_LDADD = $(tls_test_LDADD)
+
check_SCRIPTS += script_test_5.sh
check_DATA += script_test_5.stdout
MOSTLYCLEANFILES += script_test_5