[PATCH] Fix symbols truncation for i386pep target
Frediano Ziglio
freddy77@gmail.com
Fri Aug 22 08:38:56 GMT 2025
In case the symbols are between 15 and 18 characters it gets
truncated.
This is due to a mismatch in type declaration allocating only
14 bytes for x_fname field.
This can be easy verified with these commands
$ echo 'int main(void) {}' > 15_characters.c
$ gcc -c 15_characters.c
$ ld -mi386pep 15_characters.o
ld: a.exe:.comment: section below image base
$ objdump -t a.exe | grep 103
[ 0](sec -2)(fl 0x00)(ty 0)(scl 103) (nx 1) 0x0000000000000002
15_characters.
Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
---
include/coff/x86_64.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/include/coff/x86_64.h b/include/coff/x86_64.h
index 13857a8d569..1a146c26129 100644
--- a/include/coff/x86_64.h
+++ b/include/coff/x86_64.h
@@ -23,6 +23,11 @@
#ifndef COFF_X86_64_H
#define COFF_X86_64_H
+#ifdef E_FILNMLEN
+#error E_FILNMLEN already defined!
+#endif
+#define E_FILNMLEN 18 /* # characters in a file name. */
+
#include "coff/x86.h"
#define AMD64MAGIC 0x8664
--
2.50.1
More information about the Binutils
mailing list