Thanks for the pointer! I got it working. I'm currently iterating over
all FragS pointers in md_convert_frag() to find the one just before
retw.
But now I'm hitting an assertion in write.c: "Internal error in
cvt_frag_to_fill"
I checked, its this part of the code:
gas_assert (fragP->fr_next == NULL || (fragP->fr_next->fr_address -
fragP->fr_address == fragP->fr_fix));
fr_next seems to be ok, but the difference between fr_address seems to
be off by 3, fr_fix seems to be 3 higher then the difference of
fr_address in the current and the next fragP.
Any idea how that can be the case?
All I'm doing is adding an additional instruction in case I'm on the
last fragment and the current opcode is a call8 and the previous opcode
was a ldr32. So only the stuff in the if-clause is additional:
static bool
xg_build_to_stack (IStack *istack, TInsn *insn, BuildInstr *bi)
{
BuildInstr *prev_bi = NULL;
for (; bi != NULL; bi = bi->next)
{
printf("adding new instruction!\n");
if(bi->opcode == 0x3a && prev_bi->opcode == 0x86 && bi->next ==
NULL) {
if(istack->is_last_fragment == 1) {
TInsn *new_ins = (TInsn *) malloc(sizeof(TInsn));
tinsn_init (new_ins);
build_wsr_litbase_insn(new_ins);
new_ins->debug_line = insn->debug_line;
new_ins->loc_directive_seen = insn->loc_directive_seen;
istack_push(istack, new_ins);
}
}
TInsn *next_insn = istack_push_space (istack);
if (!xg_build_to_insn (next_insn, insn, bi))
return false;
prev_bi = bi;
}
return true;
}
Strangely, if I leave the check for is_last_fragment away, it works.
Thanks.
On 2023-07-31 22:20, Max Filippov wrote:
On Mon, Jul 31, 2023 at 12:57 PM <daniel@xxxxxxxxxxx> wrote:
On 2023-07-31 21:41, Max Filippov wrote:
> I don't think so. On the other hand windowed functions always begin
> with the entry instruction and end with either retw or retw.n
> instruction.
For this I would need to be able to look into the "future".
It could be done in reverse: keep track of the most recent call
instruction
and take an action once retw is seen?
Can I
traverse fragP->fr_next for that? Does fr_opcode contain the opcode of
"retw" instructions as well?
Take a look at the xtensa_mark_narrow_branches, it does this kind
of traversal.