From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <532965d3273d1c14309704f1e559999f.axp-list@archive.invalid> X-Archive-Original-Message-ID: Date: Thu, 9 May 1996 10:43:52 -0500 (CDT) From: Richard Henderson Subject: Re: gdb In-Reply-To: Linus wrote: > So, now think of the problem without a fixed assembler.. What do we get? We > get an assembler that isn't a "traditional" assembler any more: we just get a > smart pre-processor. Essentially, the assembler shouldn't emit runnable code, > it should emit runnable code _fragments_, and then the linker would be free > to pad those as it sees fit. I don't believe that ELF is compatible with the notion of subsections, at least in the same way that it supports regular sections. However, this has sparked an Idea. We introduce a new relocation type (CALL) which marks a bsr insn. We introduce a new assembler macro (call) that emits this relocation. This obviates the need for the assembler to have any special intuition about the code -- intutition that is often wrong when people are doing odd hand assembly stuff. The assembler is required to retain fixup information across CALLs. We allow the assembler to elide branch relocs that do not cross calls to help reduce the size of the object file and speed linking. When the linker goes to put all this together, based on the specifics of the situation, it expands the CALL reloc in one of three ways: (1) intra-module, to a function with the same gp: Fixes up the bsr with the function address. If exists a GPDISP relocation at the function address, we add 8. (2) intra-module, to a function with a different gp: Expands to: ldq $27,fn($gp) bsr reg,fn ldgp $gp,0(reg) where reg is extracted from the original bsr insn. This rather than hard-code $26 to support functions such as __divq that use t9. (3) inter-module: Expands to: ldq $27,fn($gp) jsr reg,($27) ldgp $gp,0(reg) So the linker will have to expand the section to accomodate the added code (worst case by a factor of four), but we already specified that the assembler must retain relocation information across the call, so the linker has everything it needs to fix things up after its changes. Comments? r~