diff options
| author | Jiaying Song <jiaying.song.cn@windriver.com> | 2025-02-05 16:06:35 +0800 |
|---|---|---|
| committer | Steve Sakoman <steve@sakoman.com> | 2025-02-12 06:25:37 -0800 |
| commit | 6d1fef08e1410eaad6ed57e480647550dbda1e3f (patch) | |
| tree | c0f5736f56a2e347713dd050c1af0424f112e042 | |
| parent | e723021fbcb710945931ed537e5d3a8bfecb2f5a (diff) | |
| download | poky-6d1fef08e1410eaad6ed57e480647550dbda1e3f.tar.gz | |
binutils: File name too long causing failure to open temporary head file in dlltool
During the execution of the command: i686-w64-mingw32-dlltool
--input-def $def_filepath --output-delaylib $filepath --dllname qemu.exe
An error occurred:
i686-w64-mingw32-dlltool: failed to open temporary head file: ..._w64_mingw32_nativesdk_qemu_8_2_2_build_plugins_libqemu_plugin_api_a_h.s
Due to the path length exceeding the Linux system's file name length
limit (NAME_MAX=255), the temporary file name generated by the
i686-w64-mingw32-dlltool command becomes too long to open. To address
this, a new temporary file name prefix is generated using tmp_prefix =
prefix_encode ("d", getpid()), ensuring that the file name does not
exceed the system's length limit.
Allow for "snnnnn.o" suffix when testing against NAME_MAX, and tidy
TMP_STUB handling by overwriting a prior nnnnn.o string rather than
copying the entire name.
(From OE-Core rev: 617df4ee1d6523ded43f156af8206dfca2c0c8ee)
Signed-off-by: Jiaying Song <jiaying.song.cn@windriver.com>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
| -rw-r--r-- | meta/recipes-devtools/binutils/binutils-2.42.inc | 1 | ||||
| -rw-r--r-- | meta/recipes-devtools/binutils/binutils/0017-dlltool-file-name-too-long.patch | 208 |
2 files changed, 209 insertions, 0 deletions
diff --git a/meta/recipes-devtools/binutils/binutils-2.42.inc b/meta/recipes-devtools/binutils/binutils-2.42.inc index 3784d26f48..8bccf8c56a 100644 --- a/meta/recipes-devtools/binutils/binutils-2.42.inc +++ b/meta/recipes-devtools/binutils/binutils-2.42.inc | |||
| @@ -37,5 +37,6 @@ SRC_URI = "\ | |||
| 37 | file://0014-Remove-duplicate-pe-dll.o-entry-deom-targ_extra_ofil.patch \ | 37 | file://0014-Remove-duplicate-pe-dll.o-entry-deom-targ_extra_ofil.patch \ |
| 38 | file://0015-gprofng-change-use-of-bignum-to-bigint.patch \ | 38 | file://0015-gprofng-change-use-of-bignum-to-bigint.patch \ |
| 39 | file://0016-CVE-2024-53589.patch \ | 39 | file://0016-CVE-2024-53589.patch \ |
| 40 | file://0017-dlltool-file-name-too-long.patch \ | ||
| 40 | " | 41 | " |
| 41 | S = "${WORKDIR}/git" | 42 | S = "${WORKDIR}/git" |
diff --git a/meta/recipes-devtools/binutils/binutils/0017-dlltool-file-name-too-long.patch b/meta/recipes-devtools/binutils/binutils/0017-dlltool-file-name-too-long.patch new file mode 100644 index 0000000000..2b759c1ee8 --- /dev/null +++ b/meta/recipes-devtools/binutils/binutils/0017-dlltool-file-name-too-long.patch | |||
| @@ -0,0 +1,208 @@ | |||
| 1 | From d95d8395b3a533461f46e8b7e55fef540fc2621b Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Jiaying Song <jiaying.song.cn@windriver.com> | ||
| 3 | Date: Tue, 13 Aug 2024 10:31:21 +0800 | ||
| 4 | Subject: [PATCH] dlltool: file name too long | ||
| 5 | |||
| 6 | During the execution of the command: i686-w64-mingw32-dlltool | ||
| 7 | --input-def $def_filepath --output-delaylib $filepath --dllname qemu.exe | ||
| 8 | An error occurred: | ||
| 9 | i686-w64-mingw32-dlltool: failed to open temporary head file: ..._w64_mingw32_nativesdk_qemu_8_2_2_build_plugins_libqemu_plugin_api_a_h.s | ||
| 10 | |||
| 11 | Due to the path length exceeding the Linux system's file name length | ||
| 12 | limit (NAME_MAX=255), the temporary file name generated by the | ||
| 13 | i686-w64-mingw32-dlltool command becomes too long to open. To address | ||
| 14 | this, a new temporary file name prefix is generated using tmp_prefix = | ||
| 15 | prefix_encode ("d", getpid()), ensuring that the file name does not | ||
| 16 | exceed the system's length limit. | ||
| 17 | |||
| 18 | Upstream-Status: Backport | ||
| 19 | [https://github.com/bminor/binutils-gdb/commit/a253bea8995323201b016fe477280c1782688ab4] | ||
| 20 | |||
| 21 | Signed-off-by: Jiaying Song <jiaying.song.cn@windriver.com> | ||
| 22 | Reviewed-by: Alan Modra <amodra@gmail.com> | ||
| 23 | |||
| 24 | Allow for "snnnnn.o" suffix when testing against NAME_MAX, and tidy | ||
| 25 | TMP_STUB handling by overwriting a prior nnnnn.o string rather than | ||
| 26 | copying the entire name. | ||
| 27 | |||
| 28 | * dlltool.c (TMP_STUB): Add "nnnnn.o" to format. | ||
| 29 | (make_one_lib_file): Localise variables. Don't copy TMP_STUB, | ||
| 30 | overwrite suffix instead. | ||
| 31 | (gen_lib_file): Similarly. | ||
| 32 | (main): Allow for max suffix when testing against NAME_MAX. | ||
| 33 | |||
| 34 | Upstream-Status: Backport | ||
| 35 | [https://github.com/bminor/binutils-gdb/commit/d0285cdf58adf04e861cd1687f7ecec65937c99d] | ||
| 36 | |||
| 37 | Signed-off-by: Jiaying Song <jiaying.song.cn@windriver.com> | ||
| 38 | --- | ||
| 39 | binutils/dlltool.c | 64 +++++++++++++++++----------------------------- | ||
| 40 | 1 file changed, 24 insertions(+), 40 deletions(-) | ||
| 41 | |||
| 42 | diff --git a/binutils/dlltool.c b/binutils/dlltool.c | ||
| 43 | index 066c99a4..94f6c34b 100644 | ||
| 44 | --- a/binutils/dlltool.c | ||
| 45 | +++ b/binutils/dlltool.c | ||
| 46 | @@ -498,7 +498,7 @@ char *tmp_stub_buf; | ||
| 47 | #define TMP_HEAD_O dlltmp (&tmp_head_o_buf, "%sh.o") | ||
| 48 | #define TMP_TAIL_S dlltmp (&tmp_tail_s_buf, "%st.s") | ||
| 49 | #define TMP_TAIL_O dlltmp (&tmp_tail_o_buf, "%st.o") | ||
| 50 | -#define TMP_STUB dlltmp (&tmp_stub_buf, "%ss") | ||
| 51 | +#define TMP_STUB dlltmp (&tmp_stub_buf, "%ssnnnnn.o") | ||
| 52 | |||
| 53 | /* This bit of assembly does jmp * .... */ | ||
| 54 | static const unsigned char i386_jtab[] = | ||
| 55 | @@ -2401,26 +2401,11 @@ make_imp_label (const char *prefix, const char *name) | ||
| 56 | static bfd * | ||
| 57 | make_one_lib_file (export_type *exp, int i, int delay) | ||
| 58 | { | ||
| 59 | - bfd * abfd; | ||
| 60 | - asymbol * exp_label; | ||
| 61 | - asymbol * iname = 0; | ||
| 62 | - asymbol * iname2; | ||
| 63 | - asymbol * iname_lab; | ||
| 64 | - asymbol ** iname_lab_pp; | ||
| 65 | - asymbol ** iname_pp; | ||
| 66 | -#ifndef EXTRA | ||
| 67 | -#define EXTRA 0 | ||
| 68 | -#endif | ||
| 69 | - asymbol * ptrs[NSECS + 4 + EXTRA + 1]; | ||
| 70 | - flagword applicable; | ||
| 71 | - char * outname = xmalloc (strlen (TMP_STUB) + 10); | ||
| 72 | - int oidx = 0; | ||
| 73 | - | ||
| 74 | - | ||
| 75 | - sprintf (outname, "%s%05d.o", TMP_STUB, i); | ||
| 76 | - | ||
| 77 | - abfd = bfd_openw (outname, HOW_BFD_WRITE_TARGET); | ||
| 78 | + char *outname = TMP_STUB; | ||
| 79 | + size_t name_len = strlen (outname); | ||
| 80 | + sprintf (outname + name_len - 7, "%05d.o", i); | ||
| 81 | |||
| 82 | + bfd *abfd = bfd_openw (outname, HOW_BFD_WRITE_TARGET); | ||
| 83 | if (!abfd) | ||
| 84 | /* xgettext:c-format */ | ||
| 85 | fatal (_("bfd_open failed open stub file: %s: %s"), | ||
| 86 | @@ -2437,9 +2422,13 @@ make_one_lib_file (export_type *exp, int i, int delay) | ||
| 87 | bfd_set_private_flags (abfd, F_INTERWORK); | ||
| 88 | #endif | ||
| 89 | |||
| 90 | - applicable = bfd_applicable_section_flags (abfd); | ||
| 91 | - | ||
| 92 | /* First make symbols for the sections. */ | ||
| 93 | + flagword applicable = bfd_applicable_section_flags (abfd); | ||
| 94 | +#ifndef EXTRA | ||
| 95 | +#define EXTRA 0 | ||
| 96 | +#endif | ||
| 97 | + asymbol *ptrs[NSECS + 4 + EXTRA + 1]; | ||
| 98 | + int oidx = 0; | ||
| 99 | for (i = 0; i < NSECS; i++) | ||
| 100 | { | ||
| 101 | sinfo *si = secdata + i; | ||
| 102 | @@ -2466,7 +2455,7 @@ make_one_lib_file (export_type *exp, int i, int delay) | ||
| 103 | |||
| 104 | if (! exp->data) | ||
| 105 | { | ||
| 106 | - exp_label = bfd_make_empty_symbol (abfd); | ||
| 107 | + asymbol *exp_label = bfd_make_empty_symbol (abfd); | ||
| 108 | exp_label->name = make_imp_label ("", exp->name); | ||
| 109 | exp_label->section = secdata[TEXT].sec; | ||
| 110 | exp_label->flags = BSF_GLOBAL; | ||
| 111 | @@ -2482,6 +2471,7 @@ make_one_lib_file (export_type *exp, int i, int delay) | ||
| 112 | /* Generate imp symbols with one underscore for Microsoft | ||
| 113 | compatibility, and with two underscores for backward | ||
| 114 | compatibility with old versions of cygwin. */ | ||
| 115 | + asymbol *iname = NULL; | ||
| 116 | if (create_compat_implib) | ||
| 117 | { | ||
| 118 | iname = bfd_make_empty_symbol (abfd); | ||
| 119 | @@ -2491,25 +2481,24 @@ make_one_lib_file (export_type *exp, int i, int delay) | ||
| 120 | iname->value = 0; | ||
| 121 | } | ||
| 122 | |||
| 123 | - iname2 = bfd_make_empty_symbol (abfd); | ||
| 124 | + asymbol *iname2 = bfd_make_empty_symbol (abfd); | ||
| 125 | iname2->name = make_imp_label ("__imp_", exp->name); | ||
| 126 | iname2->section = secdata[IDATA5].sec; | ||
| 127 | iname2->flags = BSF_GLOBAL; | ||
| 128 | iname2->value = 0; | ||
| 129 | |||
| 130 | - iname_lab = bfd_make_empty_symbol (abfd); | ||
| 131 | - | ||
| 132 | + asymbol *iname_lab = bfd_make_empty_symbol (abfd); | ||
| 133 | iname_lab->name = head_label; | ||
| 134 | iname_lab->section = bfd_und_section_ptr; | ||
| 135 | iname_lab->flags = 0; | ||
| 136 | iname_lab->value = 0; | ||
| 137 | |||
| 138 | - iname_pp = ptrs + oidx; | ||
| 139 | + asymbol **iname_pp = ptrs + oidx; | ||
| 140 | if (create_compat_implib) | ||
| 141 | ptrs[oidx++] = iname; | ||
| 142 | ptrs[oidx++] = iname2; | ||
| 143 | |||
| 144 | - iname_lab_pp = ptrs + oidx; | ||
| 145 | + asymbol **iname_lab_pp = ptrs + oidx; | ||
| 146 | ptrs[oidx++] = iname_lab; | ||
| 147 | |||
| 148 | ptrs[oidx] = 0; | ||
| 149 | @@ -3089,29 +3078,26 @@ gen_lib_file (int delay) | ||
| 150 | |||
| 151 | if (dontdeltemps < 2) | ||
| 152 | { | ||
| 153 | - char *name; | ||
| 154 | - size_t stub_len = strlen (TMP_STUB); | ||
| 155 | + char *name = TMP_STUB; | ||
| 156 | + size_t name_len = strlen (name); | ||
| 157 | |||
| 158 | - name = xmalloc (stub_len + 10); | ||
| 159 | - memcpy (name, TMP_STUB, stub_len); | ||
| 160 | for (i = 0; (exp = d_exports_lexically[i]); i++) | ||
| 161 | { | ||
| 162 | /* Don't delete non-existent stubs for PRIVATE entries. */ | ||
| 163 | if (exp->private) | ||
| 164 | continue; | ||
| 165 | - sprintf (name + stub_len, "%05d.o", i); | ||
| 166 | + sprintf (name + name_len - 7, "%05d.o", i); | ||
| 167 | if (unlink (name) < 0) | ||
| 168 | /* xgettext:c-format */ | ||
| 169 | non_fatal (_("cannot delete %s: %s"), name, strerror (errno)); | ||
| 170 | if (ext_prefix_alias) | ||
| 171 | { | ||
| 172 | - sprintf (name + stub_len, "%05d.o", i + PREFIX_ALIAS_BASE); | ||
| 173 | + sprintf (name + name_len - 7, "%05d.o", i + PREFIX_ALIAS_BASE); | ||
| 174 | if (unlink (name) < 0) | ||
| 175 | /* xgettext:c-format */ | ||
| 176 | non_fatal (_("cannot delete %s: %s"), name, strerror (errno)); | ||
| 177 | } | ||
| 178 | } | ||
| 179 | - free (name); | ||
| 180 | } | ||
| 181 | |||
| 182 | inform (_("Created lib file")); | ||
| 183 | @@ -4096,9 +4082,9 @@ main (int ac, char **av) | ||
| 184 | if (tmp_prefix == NULL) | ||
| 185 | { | ||
| 186 | /* If possible use a deterministic prefix. */ | ||
| 187 | - if (imp_name || delayimp_name) | ||
| 188 | + const char *input = imp_name ? imp_name : delayimp_name; | ||
| 189 | + if (input && strlen (input) + sizeof ("_snnnnn.o") - 1 <= NAME_MAX) | ||
| 190 | { | ||
| 191 | - const char *input = imp_name ? imp_name : delayimp_name; | ||
| 192 | tmp_prefix = xmalloc (strlen (input) + 2); | ||
| 193 | sprintf (tmp_prefix, "%s_", input); | ||
| 194 | for (i = 0; tmp_prefix[i]; i++) | ||
| 195 | @@ -4106,9 +4092,7 @@ main (int ac, char **av) | ||
| 196 | tmp_prefix[i] = '_'; | ||
| 197 | } | ||
| 198 | else | ||
| 199 | - { | ||
| 200 | - tmp_prefix = prefix_encode ("d", getpid ()); | ||
| 201 | - } | ||
| 202 | + tmp_prefix = prefix_encode ("d", getpid ()); | ||
| 203 | } | ||
| 204 | |||
| 205 | mangle_defs (); | ||
| 206 | -- | ||
| 207 | 2.34.1 | ||
| 208 | |||
