I am compiling a simple c file with gcc on Linux and using readelf to find info of symbols. The function names (and perhaps other symbols - I didnt check) are trimmed to 25 characters.
Is there a way to tell compiler/linker to keep longer symbols ?
Versions:
- Compiler : gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
<prompt>$ cat test_long_fnames_in_elf.c
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
void verly_long_function_xjsakdghajkshdlasjkldashjkldhasjklfdsjkhfsdjkhfsdjklhdsjkl_v1(uint32_t val)
{
int i = 0;
for (i = 0 ; i < val; i++)
{
printf("%d\n", i);
}
}
void verly_long_function_xjsakdghajkshdlasjkldashjkldhasjklfdsjkhfsdjkhfsdjklhdsjkl_v2(uint32_t val)
{
int i = 0;
for (i = 0 ; i < val; i++)
{
printf("This is i = %d\n", i);
}
}
int main()
{
verly_long_function_xjsakdghajkshdlasjkldashjkldhasjklfdsjkhfsdjkhfsdjklhdsjkl_v1(5);
verly_long_function_xjsakdghajkshdlasjkldashjkldhasjklfdsjkhfsdjkhfsdjklhdsjkl_v2(5);
}
<prompt>$ gcc test_long_fnames_in_elf.c -g -o test_long_fnames_in_elf.elf <prompt>$ readelf -a te.elf | grep long
<prompt>$ readelf -a test_long_fnames_in_elf.elf | grep long
41: 0000000000000000 0 FILE LOCAL DEFAULT ABS test_long_fnames_in_elf.c
52: 000000000040052d 61 FUNC GLOBAL DEFAULT 13 verly_long_function_xjsak <-- Function symbol is trimmed
62: 000000000040056a 61 FUNC GLOBAL DEFAULT 13 verly_long_function_xjsak <-- Function symbol is trimmed
<prompt>$