Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #380609
| Path | csiph.com!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Keith Thompson <Keith.S.Thompson+u@gmail.com> |
| Newsgroups | comp.lang.c |
| Subject | Re: Call to a function |
| Date | Sun, 21 Jan 2024 20:14:32 -0800 |
| Organization | None to speak of |
| Lines | 32 |
| Message-ID | <877ck2atsn.fsf@nosuchdomain.example.com> (permalink) |
| References | <call-20230922130647@ram.dialup.fu-berlin.de> <20230922081706.858@kylheku.com> <87zg1et4wv.fsf@nosuchdomain.example.com> <86jzs3de3h.fsf@linuxsc.com> <87h6n7tkv4.fsf@nosuchdomain.example.com> <86ttqf2w6p.fsf@linuxsc.com> <uha85r$ha56$1@dont-email.me> <86msw11tpp.fsf@linuxsc.com> <87leblhzud.fsf@nosuchdomain.example.com> <865y1yxiyw.fsf@linuxsc.com> <87fs11e8yz.fsf@nosuchdomain.example.com> <86bk9hjbey.fsf@linuxsc.com> <uoknaf$j1rr$2@dont-email.me> |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Transfer-Encoding | 8bit |
| Injection-Info | dont-email.me; posting-host="9cd31264156fc70cf12828e27041ba36"; logging-data="636655"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+k6zgjqzYwIG7pCtLWT4Sy" |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) |
| Cancel-Lock | sha1:rsUEgtlxkX5E6QO3BsBMFxyESdM= sha1:GNzh4tDBnmx6uv3YqNQwF4uBDEo= |
| Xref | csiph.com comp.lang.c:380609 |
Show key headers only | View raw
Lawrence D'Oliveiro <ldo@nz.invalid> writes:
> On Fri, 19 Jan 2024 12:49:57 -0800, Tim Rentsch wrote:
>> An exception to that rule is elaborate
>> function pointers, which can use very large structured values to
>> represent a pointer to function.
>
> Real-world example: PowerPC/POWER, where a function reference is two
> addresses, one for the code and the other for, I think it’s called the GOT
> (“Global Object Table”). Every piece of code assumes its GOT register has
> been set up with the right value.
According to <https://devblogs.microsoft.com/oldnewthing/20180816-00/?p=99505>:
Since each function requires its table of contents to be set
properly, a function pointer on PowerPC is not a pointer to the
first instruction. Instead, it’s a pointer to a structure
consisting of two pointers: The first pointer points to the
first instruction of the function, and the second pointer is
the table of contents for the function.
A quick experiment with a gcc powerpc cross-compiler
(powerpc-linux-gnu-gcc (Ubuntu 13.2.0-4ubuntu3) 13.2.0) indicates that
void* and function pointers are the same size, 4 bytes.
I suppose compilers *could* have used that two-pointer structure as the
representation of a function pointer. Possibly that would have broken
code that makes invalid assumptions about function pointer sizes.
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Medtronic
void Void(void) { Void(); } /* The recursive call of the void */
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Call to a function Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-01-19 12:49 -0800
Re: Call to a function Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-01-22 03:27 +0000
Re: Call to a function Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-01-21 20:14 -0800
Re: Call to a function scott@slp53.sl.home (Scott Lurndal) - 2024-01-22 16:36 +0000
Re: Call to a function Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-01-22 22:05 +0000
csiph-web