bug-mes
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug-mes] [PATCH mescc-tools 1/2] Implement "&foo>bar" and "$foo>bar".


From: Danny Milosavljevic
Subject: [bug-mes] [PATCH mescc-tools 1/2] Implement "&foo>bar" and "$foo>bar".
Date: Wed, 13 Feb 2019 16:07:49 +0100

---
 blood-elf.c                      |  2 +-
 elf_headers/elf32-ARM-debug.hex2 | 48 ++++++++++++++++----------------
 elf_headers/elf32-ARM.hex2       |  6 ++--
 elf_headers/elf32-debug.hex2     | 48 ++++++++++++++++----------------
 elf_headers/elf32.hex2           |  6 ++--
 elf_headers/elf64.hex2           |  6 ++--
 hex2_linker.c                    | 33 +++++++++++-----------
 7 files changed, 74 insertions(+), 75 deletions(-)

diff --git a/blood-elf.c b/blood-elf.c
index d8681e6..86cee51 100644
--- a/blood-elf.c
+++ b/blood-elf.c
@@ -144,7 +144,7 @@ void output_debug(struct entry* node, int stage)
                }
                else
                {
-                       file_print("%ELF_str_", output);
+                       file_print("&ELF_str_", output);
                        file_print(i->name, output);
                        file_print(">ELF_str\n&", output);
                        file_print(i->name, output);
diff --git a/elf_headers/elf32-ARM-debug.hex2 b/elf_headers/elf32-ARM-debug.hex2
index 4f3adb8..d084ab7 100644
--- a/elf_headers/elf32-ARM-debug.hex2
+++ b/elf_headers/elf32-ARM-debug.hex2
@@ -44,8 +44,8 @@
 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
-%ELF_section_headers>ELF_base  # 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
 
 00 02 00 05                    # e_flags
 
@@ -73,8 +73,8 @@
 &ELF_base                      # ph_vaddr
 &ELF_base                      # ph_physaddr
 
-%ELF_end>ELF_base              # ph_filesz
-%ELF_end>ELF_base              # ph_memsz
+&ELF_end>ELF_base              # ph_filesz
+&ELF_end>ELF_base              # ph_memsz
 
 05 00 00 00                    # p_flags
 00 00 01 00                    # alignment
@@ -85,8 +85,8 @@
 00 00 00 00                     # ph_offset
 &ELF_base                       # ph_vaddr
 &ELF_base                       # ph_physaddr
-%ELF_end>ELF_base               # ph_filesz
-%ELF_end>ELF_base               # 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
 
@@ -134,72 +134,72 @@
 
 ## FIXME: M0 for calculations?
 :ELF_section_header_text
-%ELF_shstr__text>ELF_shstr      # 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_text                       # sh_addr
-%ELF_text>ELF_base              # sh_offset
-%ELF_data>ELF_text              # 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
+&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_data                      # sh_addr
-%ELF_data>ELF_base             # sh_offset
-%ELF_sym>ELF_data              # 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
+&ELF_shstr__comment>ELF_shstr  # sh_name
 01 00 00 00                    # sh_type = SHT_PROGBITS = 1
 00 00 00 00                    # sh_flags
 &ELF_comment                   # sh_addr
-%ELF_comment>ELF_base          # sh_offset
-%ELF_shstr>ELF_comment         # 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
+&ELF_shstr__shstr>ELF_shstr    # sh_name
 03 00 00 00                    # sh_type: str-sht-strtab
 00 00 00 00                    # sh_flags
 &ELF_shstr                     # sh_addr
-%ELF_shstr>ELF_base            # sh_offset
-%ELF_section_headers>ELF_shstr # 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
+&ELF_shstr__sym>ELF_shstr      # sh_name
 02 00 00 00                    # sh_type: str-sht-symtab
 00 00 00 00                    # sh_flags
 &ELF_sym                       # sh_addr
-%ELF_sym>ELF_base              # sh_offset
-%ELF_end>ELF_sym               # 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
+&ELF_shstr__str>ELF_shstr      # sh_name
 03 00 00 00                    # sh_type: str-sht-strtab
 00 00 00 00                    # sh_flags
 &ELF_str                       # sh_addr
-%ELF_str>ELF_base              # sh_offset
-%ELF_sym>ELF_str               # 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?
diff --git a/elf_headers/elf32-ARM.hex2 b/elf_headers/elf32-ARM.hex2
index 3eeb6fb..e6eca3e 100644
--- a/elf_headers/elf32-ARM.hex2
+++ b/elf_headers/elf32-ARM.hex2
@@ -44,7 +44,7 @@
 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
+&ELF_program_headers>ELF_base  # e_phoff Address of program header table
 00 00 00 00                    # e_shoff Address of section header table
 
 00 02 00 05                    # e_flags
@@ -68,8 +68,8 @@
 &ELF_base                      # ph_vaddr
 &ELF_base                      # ph_physaddr
 
-%ELF_end>ELF_base              # ph_filesz
-%ELF_end>ELF_base              # ph_memsz
+&ELF_end>ELF_base              # ph_filesz
+&ELF_end>ELF_base              # ph_memsz
 
 05 00 00 00                    # p_flags
 00 00 01 00                    # alignment
diff --git a/elf_headers/elf32-debug.hex2 b/elf_headers/elf32-debug.hex2
index ceade25..49601b2 100644
--- a/elf_headers/elf32-debug.hex2
+++ b/elf_headers/elf32-debug.hex2
@@ -43,8 +43,8 @@
 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
-%ELF_section_headers>ELF_base  # 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
 
 00 00 00 00                    # e_flags
 
@@ -70,8 +70,8 @@
 00 00 00 00                    # ph_offset
 &ELF_base                      # ph_vaddr
 &ELF_base                      # ph_physaddr
-%ELF_end>ELF_base              # ph_filesz
-%ELF_end>ELF_base              # 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
 
@@ -84,8 +84,8 @@
 00 00 00 00                     # ph_offset
 &ELF_base                       # ph_vaddr
 &ELF_base                       # ph_physaddr
-%ELF_end>ELF_base               # ph_filesz
-%ELF_end>ELF_base               # 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
 
@@ -133,72 +133,72 @@
 
 ## FIXME: M0 for calculations?
 :ELF_section_header_text
-%ELF_shstr__text>ELF_shstr      # 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_text                       # sh_addr
-%ELF_text>ELF_base              # sh_offset
-%ELF_data>ELF_text              # 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
+&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_data                      # sh_addr
-%ELF_data>ELF_base             # sh_offset
-%ELF_sym>ELF_data              # 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
+&ELF_shstr__comment>ELF_shstr  # sh_name
 01 00 00 00                    # sh_type = SHT_PROGBITS = 1
 00 00 00 00                    # sh_flags
 &ELF_comment                   # sh_addr
-%ELF_comment>ELF_base          # sh_offset
-%ELF_shstr>ELF_comment         # 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
+&ELF_shstr__shstr>ELF_shstr    # sh_name
 03 00 00 00                    # sh_type: str-sht-strtab
 00 00 00 00                    # sh_flags
 &ELF_shstr                     # sh_addr
-%ELF_shstr>ELF_base            # sh_offset
-%ELF_section_headers>ELF_shstr # 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
+&ELF_shstr__sym>ELF_shstr      # sh_name
 02 00 00 00                    # sh_type: str-sht-symtab
 00 00 00 00                    # sh_flags
 &ELF_sym                       # sh_addr
-%ELF_sym>ELF_base              # sh_offset
-%ELF_end>ELF_sym               # 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
+&ELF_shstr__str>ELF_shstr      # sh_name
 03 00 00 00                    # sh_type: str-sht-strtab
 00 00 00 00                    # sh_flags
 &ELF_str                       # sh_addr
-%ELF_str>ELF_base              # sh_offset
-%ELF_sym>ELF_str               # 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?
diff --git a/elf_headers/elf32.hex2 b/elf_headers/elf32.hex2
index 45d365c..43f5de1 100644
--- a/elf_headers/elf32.hex2
+++ b/elf_headers/elf32.hex2
@@ -44,7 +44,7 @@
 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
+&ELF_program_headers>ELF_base  # e_phoff Address of program header table
 00 00 00 00                    # e_shoff Address of section header table
 
 00 00 00 00                    # e_flags
@@ -68,8 +68,8 @@
 &ELF_base                      # ph_vaddr
 &ELF_base                      # ph_physaddr
 
-%ELF_end>ELF_base              # ph_filesz
-%ELF_end>ELF_base              # 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
diff --git a/elf_headers/elf64.hex2 b/elf_headers/elf64.hex2
index 23d2a4a..687997b 100644
--- a/elf_headers/elf64.hex2
+++ b/elf_headers/elf64.hex2
@@ -36,7 +36,7 @@
 01 00 00 00        ## e_version Indicating original elf
 
 &ELF_text 00 00 00 00 ## e_entry Address of the entry point (Number of bytes 
this header is + Base Address)
-%ELF_program_headers>ELF_base 00 00 00 00 ## e_phoff Address of program header 
table
+&ELF_program_headers>ELF_base 00 00 00 00 ## e_phoff Address of program header 
table
 00 00 00 00 00 00 00 00 ## e_shoff Address of section header table
 
 00 00 00 00        ## e_flags
@@ -59,8 +59,8 @@
 &ELF_base 00 00 00 00 ## p_vaddr
 &ELF_base 00 00 00 00 ## p_physaddr
 
-%ELF_end>ELF_base 00 00 00 00 ## p_filesz
-%ELF_end>ELF_base 00 00 00 00 ## p_memsz
+&ELF_end>ELF_base 00 00 00 00 ## p_filesz
+&ELF_end>ELF_base 00 00 00 00 ## p_memsz
 
 01 00 00 00 00 00 00 00 ## Required alignment
 
diff --git a/hex2_linker.c b/hex2_linker.c
index 80ce2a2..47d305f 100644
--- a/hex2_linker.c
+++ b/hex2_linker.c
@@ -258,25 +258,24 @@ void storePointer(char ch, FILE* source_file)
                base = GetTarget (scratch);
        }
 
-       displacement = Architectural_displacement(target, base);
-
-       /* output calculated difference */
-       if('!' == ch)
-       {
-               if(40 == Architecture) outputPointer(displacement - 7, 1); /* 
Deal with ! */
-               else outputPointer(displacement, 1); /* Deal with ! */
-       }
-       else if('$' == ch) outputPointer(target, 2); /* Deal with $ */
-       else if('@' == ch) outputPointer(displacement, 2); /* Deal with @ */
-       else if('~' == ch) outputPointer(displacement, 3); /* Deal with ~ */
-       else if('&' == ch) outputPointer(target, 4); /* Deal with & */
-       else if('%' == ch) outputPointer(displacement, 4);  /* Deal with % */
+       if('$' == ch) outputPointer(('>' == base_sep_p) ? target - base : 
target, 2); /* Deal with $ */
+       else if('&' == ch) outputPointer(('>' == base_sep_p) ? target - base : 
target, 4); /* Deal with & */
        else
        {
-               file_print("storePointer reached impossible case: ch=", stderr);
-               fputc(ch, stderr);
-               file_print("\n", stderr);
-               exit(EXIT_FAILURE);
+               displacement = Architectural_displacement(target, base);
+
+               /* output architecture-dependent difference */
+               if('!' == ch) outputPointer(displacement, 1); /* Deal with ! */
+               else if('@' == ch) outputPointer(displacement, 2); /* Deal with 
@ */
+               else if('~' == ch) outputPointer(displacement, 3); /* Deal with 
~ */
+               else if('%' == ch) outputPointer(displacement, 4);  /* Deal 
with % */
+               else
+               {
+                       file_print("storePointer reached impossible case: ch=", 
stderr);
+                       fputc(ch, stderr);
+                       file_print("\n", stderr);
+                       exit(EXIT_FAILURE);
+               }
        }
 }
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]