History

Restore gcc10 binutils patch file

Melroy van den Berg committed 4 years ago

Commit 8116a501 parent 9095ffd1 file · +177 −0Browse files

Unified · Split

plugins/gcc10/binutils-1-fixes.patch+177−0
@@ -0,0 +1,177 @@
1+This file is part of MXE. See LICENSE.md for licensing information.
2+
3+Contains ad hoc patches for cross building.
4+
5+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
6+From: Stephen Kitt <skitt@debian.org>
7+Date: Sat, 15 Jul 2017 00:09:40 +1000
8+Subject: [PATCH 1/2] Allow the PE timestamp to be specified with
9+ SOURCE_DATE_EPOCH
10+
11+Taken from:
12+https://sources.debian.net/patches/binutils-mingw-w64/7.4/specify-timestamp.patch/
13+
14+diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c
15+index 1111111..2222222 100644
16+--- a/bfd/peXXigen.c
17++++ b/bfd/peXXigen.c
18+@@ -77,6 +77,9 @@
19+ #include <wctype.h>
20+ #endif
21+
22++#include <errno.h>
23++#include <limits.h>
24++
25+ /* NOTE: it's strange to be including an architecture specific header
26+ in what's supposed to be general (to PE/PEI) code. However, that's
27+ where the definitions are, and they don't vary per architecture
28+@@ -877,7 +880,36 @@ _bfd_XXi_only_swap_filehdr_out (bfd * ab
29+ /* Use a real timestamp by default, unless the no-insert-timestamp
30+ option was chosen. */
31+ if ((pe_data (abfd)->timestamp) == -1)
32+- H_PUT_32 (abfd, time (0), filehdr_out->f_timdat);
33++ {
34++ time_t now;
35++ char *source_date_epoch;
36++ unsigned long long epoch;
37++ char *endptr;
38++
39++ now = time (0);
40++ source_date_epoch = getenv("SOURCE_DATE_EPOCH");
41++ if (source_date_epoch) {
42++ errno = 0;
43++ epoch = strtoull(source_date_epoch, &endptr, 10);
44++ if ((errno == ERANGE && (epoch == ULLONG_MAX || epoch == 0))
45++ || (errno != 0 && epoch == 0)) {
46++ _bfd_error_handler("Environment variable $SOURCE_DATE_EPOCH: strtoull: %s\n",
47++ strerror(errno));
48++ } else if (endptr == source_date_epoch) {
49++ _bfd_error_handler("Environment variable $SOURCE_DATE_EPOCH: No digits were found: %s\n",
50++ endptr);
51++ } else if (*endptr != '\0') {
52++ _bfd_error_handler("Environment variable $SOURCE_DATE_EPOCH: Trailing garbage: %s\n",
53++ endptr);
54++ } else if (epoch > ULONG_MAX) {
55++ _bfd_error_handler("Environment variable $SOURCE_DATE_EPOCH: value must be smaller than or equal to: %lu but was found to be: %llu\n",
56++ ULONG_MAX, epoch);
57++ } else {
58++ now = epoch;
59++ }
60++ }
61++ H_PUT_32 (abfd, now, filehdr_out->f_timdat);
62++ }
63+ else
64+ H_PUT_32 (abfd, pe_data (abfd)->timestamp, filehdr_out->f_timdat);
65+
66+diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em
67+index 1111111..2222222 100644
68+--- a/ld/emultempl/pe.em
69++++ b/ld/emultempl/pe.em
70+@@ -305,7 +305,7 @@ gld${EMULATION_NAME}_add_options
71+ OPTION_USE_NUL_PREFIXED_IMPORT_TABLES},
72+ {"no-leading-underscore", no_argument, NULL, OPTION_NO_LEADING_UNDERSCORE},
73+ {"leading-underscore", no_argument, NULL, OPTION_LEADING_UNDERSCORE},
74+- {"insert-timestamp", no_argument, NULL, OPTION_INSERT_TIMESTAMP},
75++ {"insert-timestamp", optional_argument, NULL, OPTION_INSERT_TIMESTAMP},
76+ {"no-insert-timestamp", no_argument, NULL, OPTION_NO_INSERT_TIMESTAMP},
77+ #ifdef DLL_SUPPORT
78+ /* getopt allows abbreviations, so we do this to stop it
79+diff --git a/ld/emultempl/pep.em b/ld/emultempl/pep.em
80+index 1111111..2222222 100644
81+--- a/ld/emultempl/pep.em
82++++ b/ld/emultempl/pep.em
83+@@ -321,7 +321,7 @@ gld${EMULATION_NAME}_add_options
84+ {"no-bind", no_argument, NULL, OPTION_NO_BIND},
85+ {"wdmdriver", no_argument, NULL, OPTION_WDM_DRIVER},
86+ {"tsaware", no_argument, NULL, OPTION_TERMINAL_SERVER_AWARE},
87+- {"insert-timestamp", no_argument, NULL, OPTION_INSERT_TIMESTAMP},
88++ {"insert-timestamp", optional_argument, NULL, OPTION_INSERT_TIMESTAMP},
89+ {"no-insert-timestamp", no_argument, NULL, OPTION_NO_INSERT_TIMESTAMP},
90+ {"build-id", optional_argument, NULL, OPTION_BUILD_ID},
91+ {NULL, no_argument, NULL, 0}
92+diff --git a/ld/pe-dll.c b/ld/pe-dll.c
93+index 1111111..2222222 100644
94+--- a/ld/pe-dll.c
95++++ b/ld/pe-dll.c
96+@@ -27,6 +27,8 @@
97+ #include "safe-ctype.h"
98+ #include "ctf-api.h"
99+
100++#include <errno.h>
101++#include <limits.h>
102+ #include <time.h>
103+
104+ #include "ld.h"
105+@@ -1219,7 +1221,36 @@ fill_edata (bfd *abfd, struct bfd_link_info *info ATTRIBUTE_UNUSED)
106+ memset (edata_d, 0, edata_sz);
107+
108+ if (pe_data (abfd)->timestamp == -1)
109+- H_PUT_32 (abfd, time (0), edata_d + 4);
110++ {
111++ time_t now;
112++ char *source_date_epoch;
113++ unsigned long long epoch;
114++ char *endptr;
115++
116++ now = time(0);
117++ source_date_epoch = getenv("SOURCE_DATE_EPOCH");
118++ if (source_date_epoch) {
119++ errno = 0;
120++ epoch = strtoull(source_date_epoch, &endptr, 10);
121++ if ((errno == ERANGE && (epoch == ULLONG_MAX || epoch == 0))
122++ || (errno != 0 && epoch == 0)) {
123++ einfo("Environment variable $SOURCE_DATE_EPOCH: strtoull: %s\n",
124++ strerror(errno));
125++ } else if (endptr == source_date_epoch) {
126++ einfo("Environment variable $SOURCE_DATE_EPOCH: No digits were found: %s\n",
127++ endptr);
128++ } else if (*endptr != '\0') {
129++ einfo("Environment variable $SOURCE_DATE_EPOCH: Trailing garbage: %s\n",
130++ endptr);
131++ } else if (epoch > ULONG_MAX) {
132++ einfo("Environment variable $SOURCE_DATE_EPOCH: value must be smaller than or equal to: %lu but was found to be: %llu\n",
133++ ULONG_MAX, epoch);
134++ } else {
135++ now = epoch;
136++ }
137++ }
138++ H_PUT_32 (abfd, now, edata_d + 4);
139++ }
140+ else
141+ H_PUT_32 (abfd, pe_data (abfd)->timestamp, edata_d + 4);
142+
143+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
144+From: Tony Theodore <tonyt@logyst.com>
145+Date: Fri, 23 Apr 2021 09:10:50 +1000
146+Subject: [PATCH 2/2] PE/Windows x86_64: Fix weak undef symbols after image
147+ base change
148+
149+See:
150+https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=0ff9fad8bf790eebb21a1c1ee378f1c2dd1971af
151+
152+diff --git a/bfd/cofflink.c b/bfd/cofflink.c
153+index 1111111..2222222 100644
154+--- a/bfd/cofflink.c
155++++ b/bfd/cofflink.c
156+@@ -3118,6 +3118,21 @@ _bfd_coff_generic_relocate_section (bfd *output_bfd,
157+ return FALSE;
158+ case bfd_reloc_overflow:
159+ {
160++
161++ /* Ignore any weak undef symbols that may have overflowed. Due to
162++ PR ld/19011 the base address is now in the upper 64-bit address
163++ range. This means that when _bfd_final_link_relocate calculates
164++ the overlow it takes the distance between the symbol and the VMA
165++ which will now always overflow as 0 - 64-bit addr > 32-bit range
166++ of the relocation. This ends up creating PR ld/26659. */
167++ if (val == 0
168++ /* Reverse the hack where 4 is subtracted from the addend. */
169++ && (addend + 4) == 0
170++ && sym->n_sclass == C_NT_WEAK
171++ && bfd_coff_classify_symbol (output_bfd, sym)
172++ == COFF_SYMBOL_UNDEFINED)
173++ break;
174++
175+ const char *name;
176+ char buf[SYMNMLEN + 1];
177+

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t