stage0: Leverage label>base in stage0 gdb header.

* stage0/elf32-header-exit-42.hex2: Replace calculated addresses with label>base.
* stage0/elf32-body-exit-42.hex2: Likewise.
This commit is contained in:
Jan Nieuwenhuizen 2017-06-19 22:45:51 +02:00
parent f63d278cec
commit cfca4c5cc1
2 changed files with 115 additions and 139 deletions

View file

@ -29,8 +29,7 @@
:ELF_text
:_start
# exit(42)
#e8 0b 00 00 00 # call +11 <main>
e8 %main
e8 %main # call +11 <main>
00 00 00
00 00 00 00
00 00 00 00
@ -43,15 +42,6 @@ cd 80 # int $0x80
00 00 00 00
# # @210
# :main
# c9 # RET
# 00 00 00
# 00 00 00 00
# 00 00 00 00
# 00 00 00 00
# @220
:ELF_data
65 78 69 74 34 32 20 64 61 74 61 20 68 65 72 65 # exit42 data here"
@ -60,7 +50,9 @@ cd 80 # int $0x80
:ELF_str
00 # 0
:ELF_str__start
5f 73 74 61 72 74 00 # _start
:ELF_str__main
6d 61 69 6e 00 # main
00 00 00
@ -75,7 +67,7 @@ cd 80 # int $0x80
01 00 # st-shndx: 1
# _start
01 00 00 00 # st-name
%ELF_str__start>ELF_str # st-name
&_start
10 00 00 00 # st-len : &main - _start
02 # st-info = stt-func= 2
@ -83,7 +75,7 @@ cd 80 # int $0x80
01 00 # st-shndx: 1
# main
08 00 00 00 # st-name
%ELF_str__main>ELF_str # st-name
&main
10 00 00 00 # st-len : &ELF_data - main
02 # st-info = stt-func= 2

View file

@ -27,7 +27,6 @@
### elf32-header-exit-42.hex2: 32 bit elf header in hex2 for `exit 42'
:ELF_base
## ELF Header
7F 45 4C 46 # e_ident[EI_MAG0-3] ELF's magic number
01 # e_ident[EI_CLASS] Indicating 32 bit
@ -44,10 +43,10 @@
01 00 00 00 # e_version Indicating original elf
&ELF_text # e_entry Address of the entry point
#&ELF_program_headers - &ELF_base # e_phoff Address of program header table
40 00 00 00 # e_phoff Address of program header table
#&ELF_section_headers - &ELF_base # e_phoff Address of program header table
d0 00 00 00 # e_shoff Address of section header table
%ELF_program_headers>ELF_base # e_phoff Address of program header table
%ELF_section_headers>ELF_base # e_shoff Address of section header table
#d0 00 00 00 # e_shoff Address of section header table
00 00 00 00 # e_flags
@ -67,13 +66,14 @@ d0 00 00 00 # e_shoff Address of section header table
00 00 00 00
# @40
:ELF_program_headers
:ELF_program_header__text
01 00 00 00 # ph_type: PT-LOAD = 1
00 00 00 00 # ph_offset
&ELF_base # ph_vaddr
&ELF_base # ph_physaddr
00 03 00 00 # ph_filesz
00 03 00 00 # ph_memsz
%ELF_end>ELF_base # ph_filesz
%ELF_end>ELF_base # ph_memsz
07 00 00 00 # ph_flags: PF-X|PF-W|PF-R = 7
01 00 00 00 # ph_align
@ -83,22 +83,22 @@ d0 00 00 00 # e_shoff Address of section header table
00 00 00 00 # ph_offset
&ELF_base # ph_vaddr
&ELF_base # ph_physaddr
ff ff 00 00 # ph_filesz
ff ff 00 00 # ph_memsz
%ELF_end>ELF_base # ph_filesz
%ELF_end>ELF_base # ph_memsz
07 00 00 00 # ph_flags: PF-X|PF-W|PF-R = 7
01 00 00 00 # ph_align
# @80
:ELF_comment
4d 45 53 00 # MES
00 00 00 00 # align
00 00 00 00
00 00 00 00
00 00 00 00 # align
00 00 00 00 # align
4d 45 53 00 # MES
00 00 00 00 # align
00 00 00 00
00 00 00 00
00 00 00 00 # align
00 00 00 00 # align
# @a0
:ELF_shstr
@ -109,16 +109,16 @@ ff ff 00 00 # ph_memsz
2e 64 61 74 61 00 # .data
:ELF_shstr__comment
2e 63 6f 6d 6d 65 6e 74 00 # .comment
:ELF_shstr__shstrtab
:ELF_shstr__shstr
2e 73 68 73 74 72 74 61 62 00 # .shstrtab
:ELF_shstr__symtab
:ELF_shstr__sym
2e 73 79 6d 74 61 62 00 # .symtab
:ELF_shstr__strtab
:ELF_shstr__str
2e 73 74 72 74 61 62 00 # .strtab
# @d0
:ELF_sections_headers
:ELF_section_headers
00 00 00 00 # sh_name
00 00 00 00 # sh_type
00 00 00 00 # sh_flags
@ -132,88 +132,72 @@ ff ff 00 00 # ph_memsz
## FIXME: M0 for calculations?
:ELF_section_header_text
#@ELF_shstr__text - @ELF_shstr # sh_name
01 00 00 00 # sh_name
%ELF_shstr__text>ELF_shstr # sh_name
01 00 00 00 # sh_type = SHT_PROGBITS = 1
06 00 00 00 # sh_flags = SHF-ALLOC|SHF-EXEC =2 | 4 = 6
#&ELF_base # sh_addr
&ELF_text # sh_addr
#@ELF_text - @ELF_base # sh_addr
00 02 00 00 # sh_offset
#@ELF_data - @ELF_text # sh_length
20 00 00 00 # sh_length
%ELF_text>ELF_base # sh_offset
%ELF_data>ELF_text # sh_length
00 00 00 00 # sh_link
00 00 00 00 # sh_info
01 00 00 00 # sh_1?
00 00 00 00 # sh_entsize
:ELF_section_header_data
#@ELF_shstr__data - @ELF_shstr # sh_name
07 00 00 00 # sh_name
%ELF_shstr__data>ELF_shstr # sh_name
01 00 00 00 # sh_type = SHT_PROGBITS = 1
03 00 00 00 # sh_flags = SHF-WRITE|SHF-ALLOC = 1 | 2 = 3
#&ELF_base # sh_addr
&ELF_data # sh_addr
#@ELF_data - @ELF_base # sh_addr
20 02 00 00 # sh_offset
#@ELF_comment - @ELF_data # sh_length
10 00 00 00 # sh_length
%ELF_data>ELF_base # sh_offset
%ELF_sym>ELF_data # sh_length
00 00 00 00 # sh_link
00 00 00 00 # sh_info
01 00 00 00 # sh_1?
00 00 00 00 # sh_entsize
:ELF_section_header_comment
#@ELF_shstr__comment - @ELF_shstr # sh_name
0d 00 00 00 # sh_name
%ELF_shstr__comment>ELF_shstr # sh_name
01 00 00 00 # sh_type = SHT_PROGBITS = 1
00 00 00 00 # sh_flags
#&ELF_base # sh_addr
&ELF_comment # sh_addr
80 00 00 00 # sh_offset
00 00 00 00 # sh_length
%ELF_comment>ELF_base # sh_offset
%ELF_shstr>ELF_comment # sh_length
00 00 00 00 # sh_link
00 00 00 00 # sh_info
01 00 00 00 # sh_1?
00 00 00 00 # sh_entsize
:ELF_section_header_shstr
#@ELF_shstr__shstr - @ELF_shstr # sh_name
16 00 00 00 # sh_name
%ELF_shstr__shstr>ELF_shstr # sh_name
03 00 00 00 # sh_type: str-sht-strtab
00 00 00 00 # sh_flags
#&ELF_base # sh_addr
&ELF_shstr # sh_addr
a0 00 00 00 # sh_offset
30 00 00 00 # sh_length
%ELF_shstr>ELF_base # sh_offset
%ELF_section_headers>ELF_shstr # sh_length
00 00 00 00 # sh_link
00 00 00 00 # sh_info
01 00 00 00 # sh_1?
00 00 00 00 # sh_entsize
:ELF_section_header_sym
#@ELF_shstr__sym - @ELF_shstr # sh_name
20 00 00 00 # sh_name
%ELF_shstr__sym>ELF_shstr # sh_name
02 00 00 00 # sh_type: str-sht-symtab
00 00 00 00 # sh_flags
#&ELF_base # sh_addr
&ELF_sym # sh_addr
40 02 00 00 # sh_offset
30 00 00 00 # sh_length
%ELF_sym>ELF_base # sh_offset
%ELF_end>ELF_sym # sh_length
06 00 00 00 # sh_link:6
00 00 00 00 # sh_info
01 00 00 00 # sh_1?
10 00 00 00 # sh_entsize
:ELF_section_header_str
#@ELF_shstr__str - @ELF_shstr # sh_name
28 00 00 00 # sh_name
%ELF_shstr__str>ELF_shstr # sh_name
03 00 00 00 # sh_type: str-sht-strtab
00 00 00 00 # sh_flags
#&ELF_base # sh_addr
&ELF_str # sh_addr
30 02 00 00 # sh_offset
10 00 00 00 # sh_length
%ELF_str>ELF_base # sh_offset
%ELF_sym>ELF_str # sh_length
00 00 00 00 # sh_link
00 00 00 00 # sh_info
01 00 00 00 # sh_1?