Is there a way to detect a null reference function pointer during assembly or linking ?
William Tambe
tambewilliam@gmail.com
Sat Nov 30 13:59:00 GMT 2019
More information about the Binutils mailing list
Sat Nov 30 13:59:00 GMT 2019
- Previous message (by thread): Is there a way to detect a null reference function pointer during assembly or linking ?
- Next message (by thread): Titanium Strips, Plates, Rods, Wires, Baskets,
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
To supplement my previous question, a null reference function pointer
can occur when using a weak function for which there is no definition;
ie:
extern void func (void) __attribute__((weak));
int main () {
if (func)
func();
}
In the above example, func will be null if there is no default implementation.
The issue I am running into is that the value of a null reference
function pointer is not null when the executable is not loaded at the
address specified in the ELF header, because that value is computed by
offsetting a constant value from the
start of the section .text.
I would like to be able to detect a null reference function pointer,
and generate an instruction that load a null immediate value instead
of computing the null reference function pointer value by offsetting a
constant value.
Any pointers would be much appreciated.
On Fri, Nov 29, 2019 at 9:23 PM William Tambe <tambewilliam@gmail.com> wrote:
>
> Is there a way to detect a null reference function pointer during
> assembly or linking ?
>
> In fact, the target to which I ported Binutils always generate
> position-independent-code; so it is not always loaded at the address
> specified in the ELF header, and that is where I run into issues; the
> value of a null reference function pointer is not null when the
> executable is not loaded at the address specified in the ELF header,
> because that value is computed by offsetting a constant value from the
> start of the section .text.
>
> I would like to be able to detect a null reference function pointer,
> and generate an instruction that load a null immediate value instead
> of computing the null reference function pointer value by offsetting a
> constant value.
>
> Any pointers would be much appreciated.
- Previous message (by thread): Is there a way to detect a null reference function pointer during assembly or linking ?
- Next message (by thread): Titanium Strips, Plates, Rods, Wires, Baskets,
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Binutils mailing list