0

I am analyzing an ELF file using readelf command. I looked at the program headers and section headers, but found that not all of the sections were getting mapped to a segment. I am providing some part of the readelf output:

Section Headers:
[Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
[ 0]                   NULL            00000000 000000 000000 00      0   0  0
[ 1] ddr_data_nc_wt    NOBITS          70001800 0000b4 000000 00   W  0   0  1
[ 2] ddr_data_c_wb     NOBITS          70001800 0000b4 000000 00   W  0   0  1
[ 3] ddr_text_c        NOBITS          70001800 0000b4 000000 00   X  0   0  1
[ 4] m2_textboot_c     LOPROC+0        b0000000 0000c0 0023cc 00  AX  0 2952790016  2
[ 5] m2_text_c         LOPROC+0        38000000 002490 004d22 00  AX  0 2952799232 16
[ 6] m2_data_c_wb      LOPROC+5        70000000 0071c0 0006a8 00  WA  0 2952819200  2
[ 7] data_boot_c       LOPROC+5        20000000 007870 000100 00  WA  0 2953019392  4

Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings)
I (info), L (link order), G (group), x (unknown)
O (extra OS processing required) o (OS specific), p (processor specific)

There are no section groups in this file.

Program Headers:
Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
LOAD           0x0000c0 0xb0000000 0xb0000000 0x023cc 0x023cc R E 0x2
LOAD           0x002490 0xb0002400 0xb0002400 0x04d22 0x04d22 R E 0x10
LOAD           0x0071c0 0xb0007200 0xb0007200 0x006a8 0x017a8 RW  0x2
LOAD           0x007870 0xb0038000 0xb0038000 0x00100 0x08000 RW  0x4

Section to Segment mapping:
Segment Sections...
  00     m2_textboot_c
  01
  02
  03

There is no dynamic section in this file.

There are no relocations in this file.

There are no unwind sections in this file.

I find that only the section m2_textboot_c is getting mapped Segment 00, but no mention of where the other sections are mapped. Can you please give me any idea about what might be wrong and what should be done?

Also, I was wondering if there is any mechanism for loading the ELF binary onto the processor using the section headers instead of program headers. Every online help I came across loads the binary using program headers.

2 Answers 2

1

I find that only the section m2_textboot_c is getting mapped Segment 00, but no mention of where the other sections are mapped

You have probably linked this ELF image using a "custom" linker script. That script is what controls the mapping of sections to segments, and it (apparently) does not do what you wanted it to do with the other sections.

Sign up to request clarification or add additional context in comments.

Comments

0

I'm guessing that readelf performs a reverse mapping of section adresses to segments by looking at the virtual addresses. Your segments span the virtual address space 0xb0000000-0xb0040000, and the only section to be contained in that address space is indeed m2_textboot_c.

Keeping that in mind, you should probably remap the m2_text_c and m2_data_c_wb sections to 0xb0002400 and 0xb0007200 respectively, so that they match the second and third code segments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.