Skip to content
This repository was archived by the owner on Apr 3, 2020. It is now read-only.

Commit a198c47

Browse files
author
Raphael Kubo da Costa
authored
Merge pull request #365 from rakuco/backport-binutils-roll
[Backport] Update third_party/binutils to 2.26, add ICF fix
2 parents d3001c4 + 7015049 commit a198c47

File tree

9 files changed

+254
-284
lines changed

9 files changed

+254
-284
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
db44850c15da5bb295f44c295d8e5c4c97c9edec
1+
24f937cfdad77bdcd6ad8cacc542d806f3eb4b0f
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4b448a2afa4b65ffd968db57a3b233532effc88d
1+
d9064388bed0e7225b1366d80b59289b1509d7c2
Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Name: binutils
22
URL: http://www.gnu.org/software/binutils/
3-
Version: 2.25
3+
Version: 2.26
44
License: GPL v2
55
License File: NOT_SHIPPED
66
Security Critical: no
@@ -9,29 +9,24 @@ Description:
99
This directory contains i386 and amd64 binaries of the binutils tools
1010
(including gold linker).
1111

12-
They were built from binutils-2.25 using the "build-all.sh" script on a Ubuntu
13-
Precise.
12+
They were built from binutils-2.26 using the "build-all.sh" script on a
13+
Ubuntu Trusty.
1414

1515
The script creates chroots for 32bit and 64bit Ubuntu Precise and then builds
1616
binutils inside the roots. It also builds tcmalloc and links binutils with it
1717
to improve the speed of LTO.
1818

19-
Version 2.25 was released on Wed, 24 Dec 2014
19+
Version 2.26 was released on Mon, 25 Jan 2016
2020

2121
Local patches:
22-
* unlock-thin.patch for http://crbug.com/453195 from upstream change
23-
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=2cfbf2fece582c29df348104b28677c38a8301f4
24-
(Landed upstream Wed, 4 Feb 2015 - should be in 2.26)
25-
26-
* plugin-dso-fix.patch for http://crbug.com/453195 from upstream change
27-
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=3c537f7fdb11f02f7082749f3f21dfdd2c2025e8
28-
(Landed upstream Thu, 5 Feb 2015 - should be in 2.26)
29-
3022
* long-plt.patch for http://crbug.com/554017 from upstream change
3123
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=ce3e49806d505721e0875e704de0b6fcba7660ed
3224
(Landed upstream Thu, 17 Dec 2015 - should be in 2.27)
33-
The local patch has been backported to 2.25. The patch in the upstream
34-
repository currently applies cleanly to the 2.26 branch.
25+
* icf-rel.patch for https://sourceware.org/bugzilla/show_bug.cgi?id=19047
26+
from upstream change
27+
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=d114b830426300f80302ca03ff4322942f63c615
28+
(Landed upstream on 2.26 branch Thu, 5 May 2016,
29+
and on trunk Fri, 5 Feb 2016 - will be in 2.27)
3530

3631
* (build-all.sh|build-one.sh|upload.sh) scripts for building the binutils
3732
binaries and uploading them to Google storage.
@@ -53,4 +48,3 @@ To upgrade binutils, use the following steps:
5348
* Commit the change
5449

5550
See https://codereview.chromium.org/1368233002/ for an example upgrade.
56-

third_party/binutils/build-all.sh

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ if [ ! -d "$OUTPUTDIR" ]; then
2222
fi
2323

2424
# Download the source
25-
VERSION=2.25
25+
VERSION=2.26
2626
wget -c http://ftp.gnu.org/gnu/binutils/binutils-$VERSION.tar.bz2
2727

2828
# Verify the signature
@@ -46,19 +46,14 @@ tar jxf binutils-$VERSION.tar.bz2
4646
# Patch the source
4747
(
4848
cd binutils-$VERSION
49-
echo "unlock-thin.patch"
50-
echo "=================================="
51-
patch -p1 < ../unlock-thin.patch
52-
echo "----------------------------------"
53-
echo
54-
echo "plugin-dso-fix.patch"
49+
echo "long-plt.patch"
5550
echo "=================================="
56-
patch -p1 < ../plugin-dso-fix.patch
51+
patch -p1 < ../long-plt.patch
5752
echo "----------------------------------"
5853
echo
59-
echo "long-plt.patch"
54+
echo "icf-rel.patch"
6055
echo "=================================="
61-
patch -p1 < ../long-plt.patch
56+
patch -p1 < ../icf-rel.patch
6257
echo "----------------------------------"
6358
echo
6459
)
@@ -102,7 +97,7 @@ for ARCH in i386 amd64; do
10297
;;
10398
amd64)
10499
PREFIX="setarch linux64"
105-
ARCHNAME=x86_64-unknown-linux-gnu
100+
ARCHNAME=x86_64-pc-linux-gnu
106101
;;
107102
esac
108103
echo ""
@@ -117,9 +112,7 @@ for ARCH in i386 amd64; do
117112
sudo chown -R $(whoami) "$BUILDDIR/output/"
118113

119114
# Strip the output binaries
120-
for i in "$BUILDDIR/output/$ARCHNAME/bin/*"; do
121-
strip $i
122-
done
115+
strip "$BUILDDIR/output/$ARCHNAME/bin/"*
123116

124117
# Copy them out of the chroot
125118
cp -a "$BUILDDIR/output/$ARCHNAME" "$OUTPUTDIR"

third_party/binutils/icf-rel.patch

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
commit d114b830426300f80302ca03ff4322942f63c615
2+
Author: Roland McGrath <[email protected]>
3+
Date: Thu May 5 13:12:40 2016 -0700
4+
5+
2016-02-05 Sriraman Tallam <[email protected]>
6+
7+
PR gold/19047
8+
* icf.cc (get_rel_addend): New function.
9+
(get_section_contents): Move merge section addend computation to a
10+
new function. Ignore negative values for SHT_REL and SHT_RELA addends.
11+
Fix bug to not read past the length of the section.
12+
13+
Fix bug related to addend computation for MERGE sections.
14+
15+
(cherry picked from commit 84d543b7ed93bf6511cdf45791f4f0b717dfb718)
16+
17+
diff --git a/gold/ChangeLog b/gold/ChangeLog
18+
index 92b26ba..ec8dacb 100644
19+
--- a/gold/ChangeLog
20+
+++ b/gold/ChangeLog
21+
@@ -1,3 +1,11 @@
22+
+2016-02-05 Sriraman Tallam <[email protected]>
23+
+
24+
+ PR gold/19047
25+
+ * icf.cc (get_rel_addend): New function.
26+
+ (get_section_contents): Move merge section addend computation to a
27+
+ new function. Ignore negative values for SHT_REL and SHT_RELA addends.
28+
+ Fix bug to not read past the length of the section.
29+
+
30+
2015-12-17 Peter Collingbourne <[email protected]>
31+
32+
PR gold/18780
33+
diff --git a/gold/icf.cc b/gold/icf.cc
34+
index 96b7f2d..663d579 100644
35+
--- a/gold/icf.cc
36+
+++ b/gold/icf.cc
37+
@@ -213,6 +213,45 @@ preprocess_for_unique_sections(const std::vector<Section_id>& id_section,
38+
}
39+
}
40+
41+
+// For SHF_MERGE sections that use REL relocations, the addend is stored in
42+
+// the text section at the relocation offset. Read the addend value given
43+
+// the pointer to the addend in the text section and the addend size.
44+
+// Update the addend value if a valid addend is found.
45+
+// Parameters:
46+
+// RELOC_ADDEND_PTR : Pointer to the addend in the text section.
47+
+// ADDEND_SIZE : The size of the addend.
48+
+// RELOC_ADDEND_VALUE : Pointer to the addend that is updated.
49+
+
50+
+inline void
51+
+get_rel_addend(const unsigned char* reloc_addend_ptr,
52+
+ const unsigned int addend_size,
53+
+ uint64_t* reloc_addend_value)
54+
+{
55+
+ switch (addend_size)
56+
+ {
57+
+ case 0:
58+
+ break;
59+
+ case 1:
60+
+ *reloc_addend_value =
61+
+ read_from_pointer<8>(reloc_addend_ptr);
62+
+ break;
63+
+ case 2:
64+
+ *reloc_addend_value =
65+
+ read_from_pointer<16>(reloc_addend_ptr);
66+
+ break;
67+
+ case 4:
68+
+ *reloc_addend_value =
69+
+ read_from_pointer<32>(reloc_addend_ptr);
70+
+ break;
71+
+ case 8:
72+
+ *reloc_addend_value =
73+
+ read_from_pointer<64>(reloc_addend_ptr);
74+
+ break;
75+
+ default:
76+
+ gold_unreachable();
77+
+ }
78+
+}
79+
+
80+
// This returns the buffer containing the section's contents, both
81+
// text and relocs. Relocs are differentiated as those pointing to
82+
// sections that could be folded and those that cannot. Only relocs
83+
@@ -397,58 +436,36 @@ get_section_contents(bool first_iteration,
84+
uint64_t entsize =
85+
(it_v->first)->section_entsize(it_v->second);
86+
long long offset = it_a->first;
87+
-
88+
- unsigned long long addend = it_a->second;
89+
- // Ignoring the addend when it is a negative value. See the
90+
- // comments in Merged_symbol_value::Value in object.h.
91+
- if (addend < 0xffffff00)
92+
- offset = offset + addend;
93+
-
94+
- // For SHT_REL relocation sections, the addend is stored in the
95+
- // text section at the relocation offset.
96+
- uint64_t reloc_addend_value = 0;
97+
+ // Handle SHT_RELA and SHT_REL addends, only one of these
98+
+ // addends exists.
99+
+ // Get the SHT_RELA addend. For RELA relocations, we have
100+
+ // the addend from the relocation.
101+
+ uint64_t reloc_addend_value = it_a->second;
102+
+
103+
+ // Handle SHT_REL addends.
104+
+ // For REL relocations, we need to fetch the addend from the
105+
+ // section contents.
106+
const unsigned char* reloc_addend_ptr =
107+
contents + static_cast<unsigned long long>(*it_o);
108+
- switch(*it_addend_size)
109+
- {
110+
- case 0:
111+
- {
112+
- break;
113+
- }
114+
- case 1:
115+
- {
116+
- reloc_addend_value =
117+
- read_from_pointer<8>(reloc_addend_ptr);
118+
- break;
119+
- }
120+
- case 2:
121+
- {
122+
- reloc_addend_value =
123+
- read_from_pointer<16>(reloc_addend_ptr);
124+
- break;
125+
- }
126+
- case 4:
127+
- {
128+
- reloc_addend_value =
129+
- read_from_pointer<32>(reloc_addend_ptr);
130+
- break;
131+
- }
132+
- case 8:
133+
- {
134+
- reloc_addend_value =
135+
- read_from_pointer<64>(reloc_addend_ptr);
136+
- break;
137+
- }
138+
- default:
139+
- gold_unreachable();
140+
- }
141+
- offset = offset + reloc_addend_value;
142+
+
143+
+ // Update the addend value with the SHT_REL addend if
144+
+ // available.
145+
+ get_rel_addend(reloc_addend_ptr, *it_addend_size,
146+
+ &reloc_addend_value);
147+
+
148+
+ // Ignore the addend when it is a negative value. See the
149+
+ // comments in Merged_symbol_value::value in object.h.
150+
+ if (reloc_addend_value < 0xffffff00)
151+
+ offset = offset + reloc_addend_value;
152+
153+
section_size_type secn_len;
154+
+
155+
const unsigned char* str_contents =
156+
(it_v->first)->section_contents(it_v->second,
157+
&secn_len,
158+
false) + offset;
159+
+ gold_assert (offset < (long long) secn_len);
160+
+
161+
if ((secn_flags & elfcpp::SHF_STRINGS) != 0)
162+
{
163+
// String merge section.
164+
@@ -489,10 +506,14 @@ get_section_contents(bool first_iteration,
165+
}
166+
else
167+
{
168+
- // Use the entsize to determine the length.
169+
- buffer.append(reinterpret_cast<const
170+
+ // Use the entsize to determine the length to copy.
171+
+ uint64_t bufsize = entsize;
172+
+ // If entsize is too big, copy all the remaining bytes.
173+
+ if ((offset + entsize) > secn_len)
174+
+ bufsize = secn_len - offset;
175+
+ buffer.append(reinterpret_cast<const
176+
char*>(str_contents),
177+
- entsize);
178+
+ bufsize);
179+
}
180+
buffer.append("@");
181+
}

0 commit comments

Comments
 (0)