- lr_used = stub_entry->stub_offset + (p - 20 - loc);
- delta = lr_used - stub_entry->group->lr_restore;
- stub_entry->group->lr_restore = lr_used + 16;
- eh = eh_advance (htab->elf.dynobj, eh, delta);
- *eh++ = DW_CFA_offset_extended_sf;
- *eh++ = 65;
- *eh++ = -(STK_LINKER (htab) / 8) & 0x7f;
- *eh++ = DW_CFA_advance_loc + 4;
+ if (htab->params->no_tls_get_addr_regsave)
+ {
+ unsigned int lr_used, delta;
+ lr_used = stub_entry->stub_offset + (p - 20 - loc);
+ delta = lr_used - stub_entry->group->lr_restore;
+ stub_entry->group->lr_restore = lr_used + 16;
+ eh = eh_advance (htab->elf.dynobj, eh, delta);
+ *eh++ = DW_CFA_offset_extended_sf;
+ *eh++ = 65;
+ *eh++ = -(STK_LINKER (htab) / 8) & 0x7f;
+ *eh++ = DW_CFA_advance_loc + 4;
+ }
+ else
+ {
+ unsigned int cfa_updt, delta;
+ /* After the bctrl, lr has been modified so we need to emit
+ .eh_frame info saying the return address is on the stack. In
+ fact we must put the EH info at or before the call rather
+ than after it, because the EH info for a call needs to be
+ specified by that point.
+ See libgcc/unwind-dw2.c execute_cfa_program.
+ Any stack pointer update must be described immediately after
+ the instruction making the change, and since the stdu occurs
+ after saving regs we put all the reg saves and the cfa
+ change there. */
+ cfa_updt = stub_entry->stub_offset + 18 * 4;
+ delta = cfa_updt - stub_entry->group->lr_restore;
+ stub_entry->group->lr_restore
+ = stub_entry->stub_offset + (p - loc) - 4;
+ eh = eh_advance (htab->elf.dynobj, eh, delta);
+ *eh++ = DW_CFA_def_cfa_offset;
+ if (htab->opd_abi)
+ {
+ *eh++ = 128;
+ *eh++ = 1;
+ }
+ else
+ *eh++ = 96;
+ *eh++ = DW_CFA_offset_extended_sf;
+ *eh++ = 65;
+ *eh++ = (-16 / 8) & 0x7f;
+ for (i = 4; i < 12; i++)
+ {
+ *eh++ = DW_CFA_offset + i;
+ *eh++ = (htab->opd_abi ? 13 : 12) - i;
+ }
+ *eh++ = (DW_CFA_advance_loc
+ + (stub_entry->group->lr_restore - 8 - cfa_updt) / 4);
+ *eh++ = DW_CFA_def_cfa_offset;
+ *eh++ = 0;
+ for (i = 4; i < 12; i++)
+ *eh++ = DW_CFA_restore + i;
+ *eh++ = DW_CFA_advance_loc + 2;
+ }