summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/binutils
diff options
context:
space:
mode:
authorRobert Yang <liezhi.yang@windriver.com>2018-08-16 10:54:39 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-08-16 22:40:27 +0100
commitc66512c2d5432787db5d4b2743d4eb8bcc7e99c2 (patch)
treea4380c75f79f2f3905e53bee802841489f1d352c /meta/recipes-devtools/binutils
parentd4011ce0a37083b19de1769d7f18aa42d7b98137 (diff)
downloadpoky-c66512c2d5432787db5d4b2743d4eb8bcc7e99c2.tar.gz
binutils: Improve check for input file matching output file
When the assembler reports that the input and output are the same, report the file names involved, in order to help debugging. Also do not equate two files are the same if the have the same inode value but reside on different file systems. (From OE-Core rev: 83cb0938b90bab9ba727f883b8955b0b40d49a01) Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools/binutils')
-rw-r--r--meta/recipes-devtools/binutils/binutils-2.31.inc1
-rw-r--r--meta/recipes-devtools/binutils/binutils/0017-improve-check-for-input-file-matching-output-file.patch59
2 files changed, 60 insertions, 0 deletions
diff --git a/meta/recipes-devtools/binutils/binutils-2.31.inc b/meta/recipes-devtools/binutils/binutils-2.31.inc
index 02d5bcab73..6603873ba2 100644
--- a/meta/recipes-devtools/binutils/binutils-2.31.inc
+++ b/meta/recipes-devtools/binutils/binutils-2.31.inc
@@ -36,6 +36,7 @@ SRC_URI = "\
36 file://0014-Detect-64-bit-MIPS-targets.patch \ 36 file://0014-Detect-64-bit-MIPS-targets.patch \
37 file://0015-sync-with-OE-libtool-changes.patch \ 37 file://0015-sync-with-OE-libtool-changes.patch \
38 file://0016-add-i386pep-emulation-for-x86_64.patch \ 38 file://0016-add-i386pep-emulation-for-x86_64.patch \
39 file://0017-improve-check-for-input-file-matching-output-file.patch \
39" 40"
40S = "${WORKDIR}/git" 41S = "${WORKDIR}/git"
41 42
diff --git a/meta/recipes-devtools/binutils/binutils/0017-improve-check-for-input-file-matching-output-file.patch b/meta/recipes-devtools/binutils/binutils/0017-improve-check-for-input-file-matching-output-file.patch
new file mode 100644
index 0000000000..265e52633b
--- /dev/null
+++ b/meta/recipes-devtools/binutils/binutils/0017-improve-check-for-input-file-matching-output-file.patch
@@ -0,0 +1,59 @@
1From 2a50366ded329bfb39d387253450c9d5302c3503 Mon Sep 17 00:00:00 2001
2From: Robert Yang <liezhi.yang@windriver.com>
3Date: Tue, 14 Aug 2018 12:22:35 +0100
4Subject: [PATCH] as.c: Improve check for input file matching output file.
5
6When the assembler reports that the input and output are the same, report the
7file names involved, in order to help debugging. Also do not equate two files
8are the same if the have the same inode value but reside on different file
9systems.
10
11Upstream-Status: Backport
12
13Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
14---
15 gas/as.c | 27 ++++++++++++++++++++-------
16 2 files changed, 20 insertions(+), 7 deletions(-)
17
18diff --git a/gas/as.c b/gas/as.c
19index b2a908a..3105d06 100644
20--- a/gas/as.c
21+++ b/gas/as.c
22@@ -1259,14 +1259,27 @@ main (int argc, char ** argv)
23 {
24 struct stat sib;
25
26- if (stat (argv[i], &sib) == 0)
27+ /* Check that the input file and output file are different. */
28+ if (stat (argv[i], &sib) == 0
29+ && sib.st_ino == sob.st_ino
30+ /* POSIX emulating systems may support stat() but if the
31+ underlying file system does not support a file serial number
32+ of some kind then they will return 0 for the inode. So
33+ two files with an inode of 0 may not actually be the same.
34+ On real POSIX systems no ordinary file will ever have an
35+ inode of 0. */
36+ && sib.st_ino != 0
37+ /* Different files may have the same inode number if they
38+ reside on different devices, so check the st_dev field as
39+ well. */
40+ && sib.st_dev == sob.st_dev)
41 {
42- if (sib.st_ino == sob.st_ino && sib.st_ino != 0)
43- {
44- /* Don't let as_fatal remove the output file! */
45- out_file_name = NULL;
46- as_fatal (_("The input and output files must be distinct"));
47- }
48+ const char *saved_out_file_name = out_file_name;
49+
50+ /* Don't let as_fatal remove the output file! */
51+ out_file_name = NULL;
52+ as_fatal (_("The input '%s' and output '%s' files are the same"),
53+ argv[i], saved_out_file_name);
54 }
55 }
56 }
57--
582.7.4
59