[Ada] handle 'Code_Address on targets with function descriptors
Olivier Hainque
hainque@adacore.com
Thu Mar 12 13:56:00 GMT 2015
For P a subprogram, P'Code_Address is expected to return
the address at which the machine code for P starts.
It differs from 'Address on targets where function
symbol names denote the address of a function descriptor,
a record from which the code address can be fetched
(e.g. on ppc-aix).
On such targets, P'Address is expected to return
the descriptor address, and it does.
P'Code_Address should fetch the code address from the,
descriptor but we have nothing in place to achieve that
today. It just returns the same as 'Address.
The attached patch is the gigi part of a change to
fix this, relying on a tm definition that we'll be
submitting later on.
With everything in place, the testcase below is expected
to display "OK".
Bootstrapped and regtested on x86_64-pc-linux-gnu
Olivier
2015-03-12 Olivier Hainque <hainque@adacore.com>
* gcc-interface/trans.c (Attribute_to_gnu) <Code_Address case>:
On targets where a function symbol designates a function descriptor,
fetch the function code address from the descriptor.
--
with System, Ada.Unchecked_Conversion;
with Ada.Text_IO; use Ada.Text_IO;
procedure Code_Addr_P is
Addr, Code_Addr : System.Address;
type Fn_Descriptor is record
Fn_Address : System.Address;
end record;
type Descriptor_Access is access all Fn_Descriptor;
function To_Descriptor_Access is
new Ada.Unchecked_Conversion (System.Address, Descriptor_Access);
Da : Descriptor_Access;
use type System.Address;
begin
Addr := Code_Addr_P'Address;
Code_Addr := Code_Addr_P'Code_Address;
Da := To_Descriptor_Access (Addr);
if Da.Fn_Address /= Code_Addr then
raise Program_Error;
end if;
Put_Line ("OK");
end;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fndesc.diff
Type: application/octet-stream
Size: 2008 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20150312/2c672da5/attachment.obj>
More information about the Gcc-patches
mailing list