[PATCH] Fix symbols truncation for i386pep target

Jan Beulich jbeulich@suse.com
Fri Aug 22 10:20:20 GMT 2025


On 22.08.2025 12:06, Jan Beulich wrote:
> On 22.08.2025 10:38, Frediano Ziglio wrote:
>> 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>
> 
> I noticed a problem here the other day, too, but ...
> 
>> --- 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
> 
> ... this can't be quite right. Aiui the size is 18 for all PE/COFF targets,
> hence why include/coff/pe.h has the value set like this. Question therefore
> is why that #define doesn't take effect.

Ah yes, bfd/coff-i386.c (conditionally) includes coff/pe.h (as do various
others), while just bfd/coff-x86_64.c doesn't.

Jan


More information about the Binutils mailing list