]> git.wh0rd.org Git - elf2flt.git/commitdiff
Don't always update text in !pic_with_got case
authorSteve Bennett <steveb@workware.net.au>
Wed, 5 Feb 2020 01:12:36 +0000 (11:12 +1000)
committerSteve Bennett <steveb@workware.net.au>
Wed, 13 May 2020 13:02:39 +0000 (23:02 +1000)
If the text fixup has already been done early, don't do the default
text update. Code can set update_text=0 to indicate this case.

Previously the fixup done for R_MICROBLAZE_64 was being stomped on by
the default text fixup.

Signed-off-by: Steve Bennett <steveb@workware.net.au>
elf2flt.c

index ede5173bca0cf193ed8b97cf8972506b6757f38c..407eabfd21408603ac265d6950e3a08049bc26be 100644 (file)
--- a/elf2flt.c
+++ b/elf2flt.c
@@ -470,6 +470,8 @@ output_relocs (
                for (p = relpp; (relcount && (*p != NULL)); p++, relcount--) {
                        unsigned char *r_mem = NULL;
                        int relocation_needed = 0;
+                       /* Do we need to update the text segment? By default yes if not pic_with_got */
+                       int update_text = !pic_with_got;
 
 #ifdef TARGET_v850
                        /* Skip this relocation entirely if possible (we
@@ -628,6 +630,7 @@ output_relocs (
                                                + (r_mem[6] << 8)
                                                + r_mem[7];
                                        relocation_needed = 1;
+                                       update_text = 0;
                                        pflags = 0x80000000;
                                        break;
                                case R_MICROBLAZE_GOTPC_64:
@@ -825,6 +828,7 @@ output_relocs (
                                                        + (r_mem[2] << 16)
                                                        + (r_mem[3] << 24);
                                        relocation_needed = 1;
+                                       update_text = 0;
                                        break;
 
                                bad_resolved_reloc:
@@ -1442,9 +1446,10 @@ DIS29_RELOCATION:
 
                        /*
                         * for full elf relocation we have to write back the
-                        * start_code relative value to use.
+                        * start_code relative value to use. Not needed with pic_with_got
+                        * or if the fixup has already been done above (in which case update_text was set to 0)
                         */
-                       if (!pic_with_got) {
+                       if (update_text) {
 #if defined(TARGET_arm)
                                union {
                                        unsigned char c[4];