elf parser seems not working properly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-12-26 3:38 AM
After loading the elf file variables are detected incorrect (wrong address an/or size)
Two examples with output of readelf
1) used in *.c file:
uint8_t counter_error_handler __attribute__((section(".internal_ram")));
> readelf Bluepill_USB_CDC.elf -s |grep error
1374: 20002e28 1 OBJECT GLOBAL DEFAULT 9 counter_error_handler
2) used in *.cpp file:
static uint16_t blink_period;
> readelf Bluepill_USB_CDC.elf -a |grep blink
389: 2000052c 2 OBJECT LOCAL DEFAULT 8 _ZL12blink_period
in STM32CubeMonitor these variables are listed with incorrect address and size (blink_period) and incorrect address (counter_error_handler)
Is this an issue of using a c/cpp project ?
Solved! Go to Solution.
- Labels:
-
STM32CubeMonitor
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-01-04 1:50 AM
Hello Michael
This is quite strange. I am surprised by the result shown.
- For the _ZL12blink_period, in the readelf, it is shown LOCAL, so it may be not visible, but we see another similar one. Can you tell me how is declared this symbol? The "blink_period" listed 0x20000124 seems to be different. Can you check if there is global declaration for this symbol ?
- For the counter_error_handler, there is an offset of 2 bytes, which is very strange. Are you sure that file used for readelf and in STM32CubeMonitor are exactly the same ? (This offset happen most of the time when a variable is added and elf file is not updated)
Best regards
Stephane
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-01-04 1:50 AM
Hello Michael
This is quite strange. I am surprised by the result shown.
- For the _ZL12blink_period, in the readelf, it is shown LOCAL, so it may be not visible, but we see another similar one. Can you tell me how is declared this symbol? The "blink_period" listed 0x20000124 seems to be different. Can you check if there is global declaration for this symbol ?
- For the counter_error_handler, there is an offset of 2 bytes, which is very strange. Are you sure that file used for readelf and in STM32CubeMonitor are exactly the same ? (This offset happen most of the time when a variable is added and elf file is not updated)
Best regards
Stephane
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-01-04 2:08 AM
A contemporary .MAP file might be definitive.
​
G​enerally I'd have more confidence in the Linker than the average ELF parser.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-01-04 2:32 AM
Hi Stephane,
thanks for your feedback.
According to your notes I've tried to reproduce the issue with a clean build. But I can't ;)
The addresses and sizes are now correct. Don't know whats going wrong the first time - therefore sorry for any confusion ...
> readelf Bluepill_USB_CDC.elf -s | grep blink
343: 200002bc 2 OBJECT LOCAL DEFAULT 7 _ZL12blink_period
> readelf Bluepill_USB_CDC.elf -s | grep error
1208: 20002b60 1 OBJECT GLOBAL DEFAULT 8 counter_error_handler
Best regards,
Michel
