From e61d488e0f642f03d344a044a32f04abb789bd3d Mon Sep 17 00:00:00 2001 From: Tom Bloor Date: Tue, 31 Dec 2024 00:21:38 +0000 Subject: [PATCH] Add section headers for better debugging --- programs/return-42/00_elf_header.txt | 8 ++--- programs/return-42/03_string_table.txt | 3 ++ programs/return-42/04_section_header_null.txt | 29 +++++++++++++++++++ .../return-42/05_section_header_program.txt | 29 +++++++++++++++++++ .../06_section_header_string_table.txt | 29 +++++++++++++++++++ 5 files changed, 94 insertions(+), 4 deletions(-) create mode 100644 programs/return-42/03_string_table.txt create mode 100644 programs/return-42/04_section_header_null.txt create mode 100644 programs/return-42/05_section_header_program.txt create mode 100644 programs/return-42/06_section_header_string_table.txt diff --git a/programs/return-42/00_elf_header.txt b/programs/return-42/00_elf_header.txt index e26537a..d0f1b9e 100644 --- a/programs/return-42/00_elf_header.txt +++ b/programs/return-42/00_elf_header.txt @@ -48,8 +48,8 @@ 40 00 00 00 00 00 00 00 # Section Header Table Offset - e_shoff -# We dont have one! no offset -00 00 00 00 00 00 00 00 +# 64 + 56 + 16 + 16 +98 00 00 00 00 00 00 00 # Processor Flags - e_flags - No flags set 00 00 00 00 @@ -68,9 +68,9 @@ # Section Header Count - e_shnum # Set to 3 based on example -00 00 +03 00 ##Section Header String Table Index - e_shstrndx # Set to 2 based on example -00 00 +02 00 diff --git a/programs/return-42/03_string_table.txt b/programs/return-42/03_string_table.txt new file mode 100644 index 0000000..1f8d71c --- /dev/null +++ b/programs/return-42/03_string_table.txt @@ -0,0 +1,3 @@ +# String table. ".shstrab\0.text\0" -- 16 bytes +2e 73 68 73 74 72 74 61 62 00 2e 74 65 78 74 00 + diff --git a/programs/return-42/04_section_header_null.txt b/programs/return-42/04_section_header_null.txt new file mode 100644 index 0000000..e420139 --- /dev/null +++ b/programs/return-42/04_section_header_null.txt @@ -0,0 +1,29 @@ +# Section header table, section 0 -- null -- 64 bytes + +# 0x0A = offset to the name of the section in the string table +00 00 00 00 + +# 1 = type: null +00 00 00 00 + +# flags = executable | occupies memory +00 00 00 00 00 00 00 00 + +# address in virtual memory of this section +00 00 00 00 00 00 00 00 + +# offset in the file of this section (start of program code) +00 00 00 00 00 00 00 00 + +# size of this section in the file: 16 bytes +00 00 00 00 00 00 00 00 + +# sh_link -- not used for this section +00 00 00 00 00 00 00 00 + +# 0x01 = alignment code: default?? +00 00 00 00 00 00 00 00 + +# sh_entsize: not used +00 00 00 00 00 00 00 00 + diff --git a/programs/return-42/05_section_header_program.txt b/programs/return-42/05_section_header_program.txt new file mode 100644 index 0000000..028fb23 --- /dev/null +++ b/programs/return-42/05_section_header_program.txt @@ -0,0 +1,29 @@ +# Section header table, section 1 -- program text -- 64 bytes + +# 0x0A = offset to the name of the section in the string table +0a 00 00 00 + +# 1 = type: program data +01 00 00 00 + +# flags = executable | occupies memory +06 00 00 00 00 00 00 00 + +# address in virtual memory of this section +78 00 40 00 00 00 00 00 + +# offset in the file of this section (start of program code) +78 00 00 00 00 00 00 00 + +# size of this section in the file: 16 bytes +10 00 00 00 00 00 00 00 + +# sh_link -- not used for this section +00 00 00 00 00 00 00 00 + +# 0x01 = alignment code: default?? +01 00 00 00 00 00 00 00 + +# sh_entsize: not used +00 00 00 00 00 00 00 00 + diff --git a/programs/return-42/06_section_header_string_table.txt b/programs/return-42/06_section_header_string_table.txt new file mode 100644 index 0000000..a4655ee --- /dev/null +++ b/programs/return-42/06_section_header_string_table.txt @@ -0,0 +1,29 @@ +# Section header table, section 2 -- string table + +# 0x0 = offset to the name of the section in the string table +00 00 00 00 + +# 3 = type: string table +03 00 00 00 + +# 0x0 = flags +00 00 00 00 00 00 00 00 + +# 0x0 = address in virtual memory (not used) +00 00 00 00 00 00 00 00 + +# 0xB0 = offset in the file of this section (start of string table) +b0 00 00 00 00 00 00 00 + +# 0x10 = size of this section in the file: 16 bytes +10 00 00 00 00 00 00 00 + +# sh_link -- not used for this section +00 00 00 00 00 00 00 00 + +# 0x01 = alignment code: default?? +01 00 00 00 00 00 00 00 + +# sh_entsize: not used +00 00 00 00 00 00 00 00 +