summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn van Groningen2013-08-08 10:46:05 +0000
committerJohn van Groningen2013-08-08 10:46:05 +0000
commitd407ed8084a097d8a36977c4f7e4bb1ddfe1d40f (patch)
tree56213b768c38236c10a5442decd42534e8c157a7
parentdon't subtract 4 from offset of PC_RELATIVE_LONG_WORD_RELOCATION for position... (diff)
for the PC_RELATIVE_LONG_WORD_RELOCATION,
use relative to the first byte (of the relocated long word) for data, and relative to the next byte (after the relocated long word) for instructions (the ELF relocation is relative to the first byte, the COFF relocation relative to the next byte)
-rw-r--r--cgaas.c39
1 files changed, 29 insertions, 10 deletions
diff --git a/cgaas.c b/cgaas.c
index 2806837..653b952 100644
--- a/cgaas.c
+++ b/cgaas.c
@@ -646,7 +646,7 @@ static void store_label_plus_offset_in_code_section (struct label *label,int off
}
#endif
-static void store_relative_label_offset_in_code_section (struct label *label)
+static void store_relative_to_first_byte_label_offset_in_code_section (struct label *label)
{
struct relocation *new_relocation;
@@ -665,8 +665,27 @@ static void store_relative_label_offset_in_code_section (struct label *label)
#endif
}
+static void store_relative_to_next_byte_label_offset_in_code_section (struct label *label)
+{
+ struct relocation *new_relocation;
+
+ new_relocation=fast_memory_allocate_type (struct relocation);
+ ++n_code_relocations;
+
+ *last_code_relocation_l=new_relocation;
+ last_code_relocation_l=&new_relocation->next;
+ new_relocation->next=NULL;
+
+ new_relocation->relocation_label=label;
+ new_relocation->relocation_offset=CURRENT_CODE_OFFSET-4;
+ new_relocation->relocation_kind=PC_RELATIVE_LONG_WORD_RELOCATION;
#ifdef ELF_RELA
-static void store_relative_label_plus_offset_offset_in_code_section (struct label *label,int offset)
+ new_relocation->relocation_addend= -4;
+#endif
+}
+
+#ifdef ELF_RELA
+static void store_relative_to_next_byte_label_plus_offset_offset_in_code_section (struct label *label,int offset)
{
struct relocation *new_relocation;
@@ -680,7 +699,7 @@ static void store_relative_label_plus_offset_offset_in_code_section (struct labe
new_relocation->relocation_label=label;
new_relocation->relocation_offset=CURRENT_CODE_OFFSET-4;
new_relocation->relocation_kind=PC_RELATIVE_LONG_WORD_RELOCATION;
- new_relocation->relocation_addend=offset;
+ new_relocation->relocation_addend=offset - 4;
}
#endif
@@ -840,10 +859,10 @@ static void as_move_d_r (LABEL *label,int arity,int reg1)
store_c (5 | ((reg1_n & 7)<<3));
#ifdef ELF_RELA
store_l (0);
- store_relative_label_plus_offset_offset_in_code_section (label,arity);
+ store_relative_to_next_byte_label_plus_offset_offset_in_code_section (label,arity);
#else
store_l (arity);
- store_relative_label_offset_in_code_section (label);
+ store_relative_to_next_byte_label_offset_in_code_section (label);
#endif
}
@@ -1469,7 +1488,7 @@ static void as_r_a (int code,int reg1,LABEL *label)
store_c (code);
store_c (((reg1_n & 7)<<3) | 5);
store_l (0);
- store_relative_label_offset_in_code_section (label);
+ store_relative_to_next_byte_label_offset_in_code_section (label);
}
static void as_sar_i_r (int i,int reg)
@@ -3789,7 +3808,7 @@ static void as_f_a (int code1,int code2,LABEL *label,int d_freg)
store_c (code2);
store_c (5 | ((d_freg & 7)<<3));
store_l (0);
- store_relative_label_offset_in_code_section (label);
+ store_relative_to_next_byte_label_offset_in_code_section (label);
}
static void as_f_a_rexaw (int code1,int code2,LABEL *label,int d_freg)
@@ -3800,7 +3819,7 @@ static void as_f_a_rexaw (int code1,int code2,LABEL *label,int d_freg)
store_c (code2);
store_c (5 | ((d_freg & 7)<<3));
store_l (0);
- store_relative_label_offset_in_code_section (label);
+ store_relative_to_next_byte_label_offset_in_code_section (label);
}
static void as_f_i (int code1,int code2,DOUBLE *r_p,int d_freg)
@@ -5049,7 +5068,7 @@ static void write_code (void)
store_l (0);
#ifdef LINUX
if (pic_flag)
- store_relative_label_offset_in_code_section (block->block_descriptor);
+ store_relative_to_first_byte_label_offset_in_code_section (block->block_descriptor);
else
#endif
store_label_in_code_section (block->block_descriptor);
@@ -5060,7 +5079,7 @@ static void write_code (void)
store_l (0);
#ifdef LINUX
if (pic_flag)
- store_relative_label_offset_in_code_section (block->block_descriptor);
+ store_relative_to_first_byte_label_offset_in_code_section (block->block_descriptor);
else
#endif
store_label_in_code_section (block->block_descriptor);