This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH v4][C][ADA] use function descriptors instead of trampolines in C
- From: Jakub Jelinek <jakub at redhat dot com>
- To: "Uecker, Martin" <Martin dot Uecker at med dot uni-goettingen dot de>
- Cc: "law at redhat dot com" <law at redhat dot com>, "nd at arm dot com" <nd at arm dot com>, "paulkoning at comcast dot net" <paulkoning at comcast dot net>, "Szabolcs dot Nagy at arm dot com" <Szabolcs dot Nagy at arm dot com>, "msebor at gmail dot com" <msebor at gmail dot com>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, "Wilco dot Dijkstra at arm dot com" <Wilco dot Dijkstra at arm dot com>, "ebotcazou at adacore dot com" <ebotcazou at adacore dot com>, "joseph at codesourcery dot com" <joseph at codesourcery dot com>
- Date: Tue, 18 Dec 2018 17:42:12 +0100
- Subject: Re: [PATCH v4][C][ADA] use function descriptors instead of trampolines in C
- References: <1545000327.30232.11.camel@med.uni-goettingen.de> <05b12e7e-b6dd-fa8d-94cb-35ec9c512950@arm.com> <1545070952.3328.5.camel@med.uni-goettingen.de> <da4263fd-9b70-7bd8-f662-e12a335dc4a7@arm.com> <5896AE4C-D296-4FAF-A809-7BACA532BBF5@comcast.net> <20181218153209.GP23305@tucnak> <81804969-da3b-80b8-98d2-beb31cd19541@redhat.com> <20181218162440.GQ23305@tucnak> <1545150562.7930.4.camel@med.uni-goettingen.de> <1545150827.16327.1.camel@med.uni-goettingen.de>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Tue, Dec 18, 2018 at 04:33:48PM +0000, Uecker, Martin wrote:
> > Yes, something like this. If the trampolines are pre-allocated, this could
> > even avoid the need to clear the cache on archs where this is needed.
>
> And if we can make the trampolines be all the same (and it somehow derived
> from the IP where it has to look for the static chain), we could map the
> same page of pre-allocated trampolines and not use memory on platforms
> with virtual memory.
Yeah, if it is e.g. a pair of executable page and data page right after it,
say for x86_64 page of:
pushq $0
jmp .L1
pushq $1
jmp .L1
...
push $NNN
jmp .L1
# Almost at the end of page
.L1:
decode the above pushed number
read + decrypt the data (both where to jump to and static chain)
set static chain reg to the static chain data
jmp *function pointer
it could just mmap both pages at once PROT_NONE, and then mmap one from the
file and fill in data in the other page. Or perhaps one executable and two
data pages, depending on the exact sizes of needed data vs. code.
Jakub