Gitweb links:
...log
http://git.netsurf-browser.org/toolchains.git/shortlog/eac6cf5f4b0ea82f2f6157a8782dee5016d67af5
...commit
http://git.netsurf-browser.org/toolchains.git/commit/eac6cf5f4b0ea82f2f6157a8782dee5016d67af5
...tree
http://git.netsurf-browser.org/toolchains.git/tree/eac6cf5f4b0ea82f2f6157a8782dee5016d67af5
The branch, master has been updated
via eac6cf5f4b0ea82f2f6157a8782dee5016d67af5 (commit)
from 54a65384336e70df299daee76553131954a3a0fa (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/toolchains.git/commit/?id=eac6cf5f4b0ea82f2f6157a8782dee5016d67af5
commit eac6cf5f4b0ea82f2f6157a8782dee5016d67af5
Author: John-Mark Bell <[email protected]>
Commit: John-Mark Bell <[email protected]>
arm-riscos-gnueabi: set up GOT if there is one
Non-PIC (static) binaries may still link against PIC library code
and so require the GOT to be discoverable. Now that it is expected
to be found via the runtime workspace entry at &8038, we must
ensure that static binaries converted to AIF using elf2aif behave
correctly.
Unfortunately, this scheme will fallover if ever the OS makes the
text segment read-only (as &8038 is in the middle of the AIF
header, so cannot have GOTT_BASE baked in at conversion time).
diff --git a/arm-riscos-gnueabi/recipes/patches/gccsdk/elf2aif-eabi-support.p
b/arm-riscos-gnueabi/recipes/patches/gccsdk/elf2aif-eabi-support.p
index 1d8b841..ec0eaa3 100644
--- a/arm-riscos-gnueabi/recipes/patches/gccsdk/elf2aif-eabi-support.p
+++ b/arm-riscos-gnueabi/recipes/patches/gccsdk/elf2aif-eabi-support.p
@@ -2,7 +2,7 @@ Index: elf2aif/src/elf2aif.c
===================================================================
--- elf2aif/src/elf2aif.c (revision 7698)
+++ elf2aif/src/elf2aif.c (working copy)
-@@ -72,12 +72,13 @@
+@@ -72,12 +72,14 @@
} aifheader_t;
static int opt_verbose = 0;
@@ -11,13 +11,14 @@ Index: elf2aif/src/elf2aif.c
static Elf32_External_Ehdr elf_ehdr;
static phdr_list_t *elf_phdrlistP;
static const char *elf_filename;
++static uint32_t got_addr = 0;
-static const unsigned int aifcode[] = {
+static const uint32_t aifcode[] = {
0xE1A00000, /* NOP (BL decompress) */
0xE1A00000, /* NOP (BL self-relocate) */
0xEB00000C, /* BL zero-init */
-@@ -113,6 +114,24 @@
+@@ -113,6 +115,25 @@
0xEAFFFFFB /* B zeroloop */
};
@@ -31,18 +32,19 @@ Index: elf2aif/src/elf2aif.c
+};
+
+static const uint32_t eabi_crt0code[] = {
-+ 0xE59F3010, /* LDR R3, =crt1_data */
-+ 0xE583000C, /* STR R0, [R3, #12] */
-+ 0xE3A00002, /* MOV R0, #2 */
-+ 0xEF059D01, /* SWI ARMEABISupport_AbortOp */
-+ 0xE1A00003 /* MOV R0, R3 */
++ 0xE59F0010, /* LDR R0, =crt1_data */
++ 0xE59F1004, /* LDR R1, =got_addr */
++ 0xE3A020FF, /* MOV R2, #&FF */
++ 0xEA000000, /* B go */
++ 0x00000000, /* got_addr (*) */
++/* go: */
+ /* B __main */
+};
+
/* Read a little-endian 'short' value. */
static uint16_t
RdShort (const uint8_t sh[2])
-@@ -143,6 +162,7 @@
+@@ -143,6 +164,7 @@
fprintf (stderr, "Usage: elf2aif [options] <ELF file> [<AIF file>]\n"
"Convert static ARM ELF binary to AIF (Acorn Image Format) binary.\n"
"Options:\n"
@@ -50,7 +52,7 @@ Index: elf2aif/src/elf2aif.c
" -v, --verbose prints informational messages during
processing\n"
" --help display this help and exit\n"
" --version output version information and exit\n");
-@@ -201,7 +221,8 @@
+@@ -201,7 +223,8 @@
return EXIT_FAILURE;
}
@@ -60,7 +62,105 @@ Index: elf2aif/src/elf2aif.c
{
fprintf (stderr, "ELF file '%s' is not for ARM\n", elf_filename);
return EXIT_FAILURE;
-@@ -503,6 +524,37 @@
+@@ -344,6 +367,97 @@
+ }
+
+ static int
++e2a_readshdr (FILE * elfhandle)
++{
++ Elf32_External_Shdr shstentry;
++ uint32_t shoffset, shentrysize, shentrycount, shstrndx;
++ uint32_t shstoffset, shstsize;
++ char *shst;
++
++ if ((shoffset = RdLong (elf_ehdr.e_shoff)) == 0
++ || (shentrycount = RdShort (elf_ehdr.e_shnum)) == 0)
++ {
++ fprintf (stderr, "ELF file '%s' does not have section headers\n",
++ elf_filename);
++ return EXIT_FAILURE;
++ }
++
++ if ((shentrysize = RdShort (elf_ehdr.e_shentsize)) < sizeof
(Elf32_External_Shdr))
++ {
++ fprintf (stderr, "Size section header entry is too small\n");
++ return EXIT_FAILURE;
++ }
++
++ if ((shstrndx = RdShort (elf_ehdr.e_shstrndx)) >= shentrycount) {
++ fprintf (stderr, "String table index out of bounds\n");
++ return EXIT_FAILURE;
++ }
++
++ if (fseek (elfhandle, shoffset + (shstrndx * shentrysize), SEEK_SET) != 0
++ || fread (&shstentry, sizeof (Elf32_External_Shdr), 1, elfhandle) != 1)
++ {
++ fprintf (stderr, "Failed to read section header string table header\n");
++ return EXIT_FAILURE;
++ }
++
++ if ((shstoffset = RdLong (shstentry.sh_offset)) == 0)
++ {
++ fprintf (stderr, "Section header string table data missing\n");
++ return EXIT_FAILURE;
++ }
++
++ if ((shstsize = RdLong (shstentry.sh_size)) == 0)
++ {
++ fprintf (stderr, "Invalid section header string table size\n");
++ return EXIT_FAILURE;
++ }
++
++ if ((shst = malloc (shstsize)) == NULL)
++ {
++ fprintf (stderr, "Out of memory\n");
++ return EXIT_FAILURE;
++ }
++
++ if (fseek (elfhandle, shstoffset, SEEK_SET) != 0
++ || fread (shst, 1, shstsize, elfhandle) != shstsize)
++ {
++ fprintf (stderr, "Failed to read section header string table\n");
++ return EXIT_FAILURE;
++ }
++
++ while (shentrycount)
++ {
++ Elf32_External_Shdr shentry;
++ uint32_t shnameoff;
++
++ if (fseek (elfhandle, shoffset, SEEK_SET) != 0
++ || fread (&shentry, sizeof (Elf32_External_Shdr), 1, elfhandle) !=
1)
++ {
++ fprintf (stderr, "Failed to read section header entry\n");
++ return EXIT_FAILURE;
++ }
++
++ if ((shnameoff = RdLong (shentry.sh_name)) >= shstsize)
++ {
++ fprintf (stderr, "Section name out of bounds\n");
++ return EXIT_FAILURE;
++ }
++
++ if (strcmp ((shst + shnameoff), ".got") == 0)
++ {
++ got_addr = RdLong (shentry.sh_addr);
++ }
++
++ shoffset += shentrysize;
++ --shentrycount;
++ }
++
++ free (shst);
++
++ return EXIT_SUCCESS;
++}
++
++static int
+ e2a_copy (FILE * elfhandle, FILE * aifhandle)
+ {
+ const phdr_list_t *phdrP;
+@@ -503,6 +617,40 @@
return EXIT_FAILURE;
}
@@ -86,8 +186,11 @@ Index: elf2aif/src/elf2aif.c
+ fprintf (stderr, "crt0 code not as expected\n");
+ return EXIT_FAILURE;
+ }
++ /* Inject GOT address */
++ memcpy (crt0, eabi_crt0code, sizeof (crt0));
++ crt0[4] = got_addr;
+ if (fseek (aifhandle, (exec_addr - load_addr), SEEK_SET) != 0 ||
-+ fwrite (eabi_crt0code, sizeof (crt0), 1, aifhandle) != 1 ||
++ fwrite (crt0, sizeof (crt0), 1, aifhandle) != 1 ||
+ fseek (aifhandle, aifend, SEEK_SET) != 0)
+ {
+ fprintf (stderr, "Failed to write crt0\n");
@@ -98,7 +201,15 @@ Index: elf2aif/src/elf2aif.c
return EXIT_SUCCESS;
}
-@@ -683,6 +735,9 @@
+@@ -557,6 +705,7 @@
+ elf_filename = elffilename;
+
+ if (e2a_readehdr (elfhandle) == EXIT_SUCCESS
++ && e2a_readshdr (elfhandle) == EXIT_SUCCESS
+ && e2a_readphdr (elfhandle) == EXIT_SUCCESS
+ && e2a_copy (elfhandle, aifhandle) == EXIT_SUCCESS)
+ status = EXIT_SUCCESS;
+@@ -683,6 +832,9 @@
fprintf (stderr, "Warning: extra options/arguments ignored\n");
return EXIT_SUCCESS;
}
diff --git
a/arm-riscos-gnueabi/recipes/patches/gccsdk/unixlib-static-eabi-aif.p
b/arm-riscos-gnueabi/recipes/patches/gccsdk/unixlib-static-eabi-aif.p
new file mode 100644
index 0000000..22a32d9
--- /dev/null
+++ b/arm-riscos-gnueabi/recipes/patches/gccsdk/unixlib-static-eabi-aif.p
@@ -0,0 +1,53 @@
+Index: libunixlib/incl-local/internal/asm_dec.s
+===================================================================
+--- libunixlib/incl-local/internal/asm_dec.s (revision 7698)
++++ libunixlib/incl-local/internal/asm_dec.s (working copy)
+@@ -215,6 +215,7 @@
+
+ @ A few of these are required to build SUL.
+ .set XARMEABISupport_MemoryOp, 0x59D00 + X_Bit
++.set ARMEABISupport_AbortOp, 0x59D01
+ .set XARMEABISupport_AbortOp, 0x59D01 + X_Bit
+ .set XARMEABISupport_StackOp, 0x59D02 + X_Bit
+ .set XARMEABISupport_Cleanup, 0x59D03 + X_Bit
+
+Index: libunixlib/sys/_syslib.s
+===================================================================
+--- libunixlib/sys/_syslib.s (revision 7698)
++++ libunixlib/sys/_syslib.s (working copy)
+@@ -108,6 +108,35 @@
+
+ MOV v1, a1
+
++#ifdef __ARM_EABI__
++ @ Check to see if this is a static EABI binary produced by elf2aif
++ TEQ a3, #0xFF
++ BNE not_eabi_aif
++
++ @ It was. a2 contains the GOT address (or 0 if none)
++ TEQ a2, #0
++ @ Create a fake runtime array (overwriting bits of AIF header)
++ MOVNE a3, #0x8000
++ STRNE a2, [a3, #(52 + 20)]
++ MOVNE a2, #0
++ STRNE a2, [a3, #(52 + 24)]
++ STRNE a2, [a3, #(52 + 28)]
++ STRNE a2, [a3, #(52 + 32)]
++ @ and fill in the workspace (ditto)
++ STRNE a2, [a3, #(52 + 0)]
++ STRNE a2, [a3, #(52 + 8)]
++ STRNE a2, [a3, #(52 + 12)]
++ STRNE a2, [a3, #(52 + 16)]
++ ADDNE a2, a3, #(52 + 20)
++ STRNE a2, [a3, #(52 + 4)]
++
++ @ Finally, enable the ARMEABISupport abort handler
++ MOV a1, #2
++ SWI ARMEABISupport_AbortOp
++
++not_eabi_aif:
++#endif
++
+ PIC_LOAD v4
+
+ @ Read environment parameters
-----------------------------------------------------------------------
Summary of changes:
.../recipes/patches/gccsdk/elf2aif-eabi-support.p | 135 ++++++++++++++++++--
.../patches/gccsdk/unixlib-static-eabi-aif.p | 53 ++++++++
2 files changed, 176 insertions(+), 12 deletions(-)
create mode 100644
arm-riscos-gnueabi/recipes/patches/gccsdk/unixlib-static-eabi-aif.p
diff --git a/arm-riscos-gnueabi/recipes/patches/gccsdk/elf2aif-eabi-support.p
b/arm-riscos-gnueabi/recipes/patches/gccsdk/elf2aif-eabi-support.p
index 1d8b841..ec0eaa3 100644
--- a/arm-riscos-gnueabi/recipes/patches/gccsdk/elf2aif-eabi-support.p
+++ b/arm-riscos-gnueabi/recipes/patches/gccsdk/elf2aif-eabi-support.p
@@ -2,7 +2,7 @@ Index: elf2aif/src/elf2aif.c
===================================================================
--- elf2aif/src/elf2aif.c (revision 7698)
+++ elf2aif/src/elf2aif.c (working copy)
-@@ -72,12 +72,13 @@
+@@ -72,12 +72,14 @@
} aifheader_t;
static int opt_verbose = 0;
@@ -11,13 +11,14 @@ Index: elf2aif/src/elf2aif.c
static Elf32_External_Ehdr elf_ehdr;
static phdr_list_t *elf_phdrlistP;
static const char *elf_filename;
++static uint32_t got_addr = 0;
-static const unsigned int aifcode[] = {
+static const uint32_t aifcode[] = {
0xE1A00000, /* NOP (BL decompress) */
0xE1A00000, /* NOP (BL self-relocate) */
0xEB00000C, /* BL zero-init */
-@@ -113,6 +114,24 @@
+@@ -113,6 +115,25 @@
0xEAFFFFFB /* B zeroloop */
};
@@ -31,18 +32,19 @@ Index: elf2aif/src/elf2aif.c
+};
+
+static const uint32_t eabi_crt0code[] = {
-+ 0xE59F3010, /* LDR R3, =crt1_data */
-+ 0xE583000C, /* STR R0, [R3, #12] */
-+ 0xE3A00002, /* MOV R0, #2 */
-+ 0xEF059D01, /* SWI ARMEABISupport_AbortOp */
-+ 0xE1A00003 /* MOV R0, R3 */
++ 0xE59F0010, /* LDR R0, =crt1_data */
++ 0xE59F1004, /* LDR R1, =got_addr */
++ 0xE3A020FF, /* MOV R2, #&FF */
++ 0xEA000000, /* B go */
++ 0x00000000, /* got_addr (*) */
++/* go: */
+ /* B __main */
+};
+
/* Read a little-endian 'short' value. */
static uint16_t
RdShort (const uint8_t sh[2])
-@@ -143,6 +162,7 @@
+@@ -143,6 +164,7 @@
fprintf (stderr, "Usage: elf2aif [options] <ELF file> [<AIF file>]\n"
"Convert static ARM ELF binary to AIF (Acorn Image Format) binary.\n"
"Options:\n"
@@ -50,7 +52,7 @@ Index: elf2aif/src/elf2aif.c
" -v, --verbose prints informational messages during
processing\n"
" --help display this help and exit\n"
" --version output version information and exit\n");
-@@ -201,7 +221,8 @@
+@@ -201,7 +223,8 @@
return EXIT_FAILURE;
}
@@ -60,7 +62,105 @@ Index: elf2aif/src/elf2aif.c
{
fprintf (stderr, "ELF file '%s' is not for ARM\n", elf_filename);
return EXIT_FAILURE;
-@@ -503,6 +524,37 @@
+@@ -344,6 +367,97 @@
+ }
+
+ static int
++e2a_readshdr (FILE * elfhandle)
++{
++ Elf32_External_Shdr shstentry;
++ uint32_t shoffset, shentrysize, shentrycount, shstrndx;
++ uint32_t shstoffset, shstsize;
++ char *shst;
++
++ if ((shoffset = RdLong (elf_ehdr.e_shoff)) == 0
++ || (shentrycount = RdShort (elf_ehdr.e_shnum)) == 0)
++ {
++ fprintf (stderr, "ELF file '%s' does not have section headers\n",
++ elf_filename);
++ return EXIT_FAILURE;
++ }
++
++ if ((shentrysize = RdShort (elf_ehdr.e_shentsize)) < sizeof
(Elf32_External_Shdr))
++ {
++ fprintf (stderr, "Size section header entry is too small\n");
++ return EXIT_FAILURE;
++ }
++
++ if ((shstrndx = RdShort (elf_ehdr.e_shstrndx)) >= shentrycount) {
++ fprintf (stderr, "String table index out of bounds\n");
++ return EXIT_FAILURE;
++ }
++
++ if (fseek (elfhandle, shoffset + (shstrndx * shentrysize), SEEK_SET) != 0
++ || fread (&shstentry, sizeof (Elf32_External_Shdr), 1, elfhandle) != 1)
++ {
++ fprintf (stderr, "Failed to read section header string table header\n");
++ return EXIT_FAILURE;
++ }
++
++ if ((shstoffset = RdLong (shstentry.sh_offset)) == 0)
++ {
++ fprintf (stderr, "Section header string table data missing\n");
++ return EXIT_FAILURE;
++ }
++
++ if ((shstsize = RdLong (shstentry.sh_size)) == 0)
++ {
++ fprintf (stderr, "Invalid section header string table size\n");
++ return EXIT_FAILURE;
++ }
++
++ if ((shst = malloc (shstsize)) == NULL)
++ {
++ fprintf (stderr, "Out of memory\n");
++ return EXIT_FAILURE;
++ }
++
++ if (fseek (elfhandle, shstoffset, SEEK_SET) != 0
++ || fread (shst, 1, shstsize, elfhandle) != shstsize)
++ {
++ fprintf (stderr, "Failed to read section header string table\n");
++ return EXIT_FAILURE;
++ }
++
++ while (shentrycount)
++ {
++ Elf32_External_Shdr shentry;
++ uint32_t shnameoff;
++
++ if (fseek (elfhandle, shoffset, SEEK_SET) != 0
++ || fread (&shentry, sizeof (Elf32_External_Shdr), 1, elfhandle) !=
1)
++ {
++ fprintf (stderr, "Failed to read section header entry\n");
++ return EXIT_FAILURE;
++ }
++
++ if ((shnameoff = RdLong (shentry.sh_name)) >= shstsize)
++ {
++ fprintf (stderr, "Section name out of bounds\n");
++ return EXIT_FAILURE;
++ }
++
++ if (strcmp ((shst + shnameoff), ".got") == 0)
++ {
++ got_addr = RdLong (shentry.sh_addr);
++ }
++
++ shoffset += shentrysize;
++ --shentrycount;
++ }
++
++ free (shst);
++
++ return EXIT_SUCCESS;
++}
++
++static int
+ e2a_copy (FILE * elfhandle, FILE * aifhandle)
+ {
+ const phdr_list_t *phdrP;
+@@ -503,6 +617,40 @@
return EXIT_FAILURE;
}
@@ -86,8 +186,11 @@ Index: elf2aif/src/elf2aif.c
+ fprintf (stderr, "crt0 code not as expected\n");
+ return EXIT_FAILURE;
+ }
++ /* Inject GOT address */
++ memcpy (crt0, eabi_crt0code, sizeof (crt0));
++ crt0[4] = got_addr;
+ if (fseek (aifhandle, (exec_addr - load_addr), SEEK_SET) != 0 ||
-+ fwrite (eabi_crt0code, sizeof (crt0), 1, aifhandle) != 1 ||
++ fwrite (crt0, sizeof (crt0), 1, aifhandle) != 1 ||
+ fseek (aifhandle, aifend, SEEK_SET) != 0)
+ {
+ fprintf (stderr, "Failed to write crt0\n");
@@ -98,7 +201,15 @@ Index: elf2aif/src/elf2aif.c
return EXIT_SUCCESS;
}
-@@ -683,6 +735,9 @@
+@@ -557,6 +705,7 @@
+ elf_filename = elffilename;
+
+ if (e2a_readehdr (elfhandle) == EXIT_SUCCESS
++ && e2a_readshdr (elfhandle) == EXIT_SUCCESS
+ && e2a_readphdr (elfhandle) == EXIT_SUCCESS
+ && e2a_copy (elfhandle, aifhandle) == EXIT_SUCCESS)
+ status = EXIT_SUCCESS;
+@@ -683,6 +832,9 @@
fprintf (stderr, "Warning: extra options/arguments ignored\n");
return EXIT_SUCCESS;
}
diff --git
a/arm-riscos-gnueabi/recipes/patches/gccsdk/unixlib-static-eabi-aif.p
b/arm-riscos-gnueabi/recipes/patches/gccsdk/unixlib-static-eabi-aif.p
new file mode 100644
index 0000000..22a32d9
--- /dev/null
+++ b/arm-riscos-gnueabi/recipes/patches/gccsdk/unixlib-static-eabi-aif.p
@@ -0,0 +1,53 @@
+Index: libunixlib/incl-local/internal/asm_dec.s
+===================================================================
+--- libunixlib/incl-local/internal/asm_dec.s (revision 7698)
++++ libunixlib/incl-local/internal/asm_dec.s (working copy)
+@@ -215,6 +215,7 @@
+
+ @ A few of these are required to build SUL.
+ .set XARMEABISupport_MemoryOp, 0x59D00 + X_Bit
++.set ARMEABISupport_AbortOp, 0x59D01
+ .set XARMEABISupport_AbortOp, 0x59D01 + X_Bit
+ .set XARMEABISupport_StackOp, 0x59D02 + X_Bit
+ .set XARMEABISupport_Cleanup, 0x59D03 + X_Bit
+
+Index: libunixlib/sys/_syslib.s
+===================================================================
+--- libunixlib/sys/_syslib.s (revision 7698)
++++ libunixlib/sys/_syslib.s (working copy)
+@@ -108,6 +108,35 @@
+
+ MOV v1, a1
+
++#ifdef __ARM_EABI__
++ @ Check to see if this is a static EABI binary produced by elf2aif
++ TEQ a3, #0xFF
++ BNE not_eabi_aif
++
++ @ It was. a2 contains the GOT address (or 0 if none)
++ TEQ a2, #0
++ @ Create a fake runtime array (overwriting bits of AIF header)
++ MOVNE a3, #0x8000
++ STRNE a2, [a3, #(52 + 20)]
++ MOVNE a2, #0
++ STRNE a2, [a3, #(52 + 24)]
++ STRNE a2, [a3, #(52 + 28)]
++ STRNE a2, [a3, #(52 + 32)]
++ @ and fill in the workspace (ditto)
++ STRNE a2, [a3, #(52 + 0)]
++ STRNE a2, [a3, #(52 + 8)]
++ STRNE a2, [a3, #(52 + 12)]
++ STRNE a2, [a3, #(52 + 16)]
++ ADDNE a2, a3, #(52 + 20)
++ STRNE a2, [a3, #(52 + 4)]
++
++ @ Finally, enable the ARMEABISupport abort handler
++ MOV a1, #2
++ SWI ARMEABISupport_AbortOp
++
++not_eabi_aif:
++#endif
++
+ PIC_LOAD v4
+
+ @ Read environment parameters
--
Cross-compilation toolchains and environments
_______________________________________________
netsurf-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]