Deutsch English Français Italiano |
<v5m41l$39qob$4@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: bart <bc@freeuk.com> Newsgroups: comp.lang.c Subject: Re: Baby X is bor nagain Date: Fri, 28 Jun 2024 11:41:58 +0100 Organization: A noiseless patient Spider Lines: 47 Message-ID: <v5m41l$39qob$4@dont-email.me> References: <v494f9$von8$1@dont-email.me> <v53i4s$33k73$2@dont-email.me> <v53lf7$34huc$1@dont-email.me> <v53vh6$368vf$1@dont-email.me> <v54se1$3bqsk$1@dont-email.me> <20240624160941.0000646a@yahoo.com> <v5bu5r$va3a$1@dont-email.me> <20240624181006.00003b94@yahoo.com> <v5c86d$11ac7$1@dont-email.me> <JEheO.108086$ED9b.74955@fx11.iad> <v5cblg$11q0j$1@dont-email.me> <gEieO.108089$ED9b.25598@fx11.iad> <20240625113616.000075e0@yahoo.com> <mUzeO.141609$Cqra.55051@fx10.iad> <v5elql$1jmii$1@dont-email.me> <m3BeO.24907$Gurd.16179@fx34.iad> <v5empd$1jndv$2@dont-email.me> <v5eph4$1k6a9$1@dont-email.me> <87ed8jnbmf.fsf@bsb.me.uk> <v5jhls$2m7np$1@dont-email.me> <867ceadtih.fsf@linuxsc.com> <v5krsp$2v9va$1@dont-email.me> <20240627202641.177@kylheku.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Fri, 28 Jun 2024 12:41:58 +0200 (CEST) Injection-Info: dont-email.me; posting-host="e7f1b554b99247d34cf39342a3f15f64"; logging-data="3468043"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18TUyhErkex5hZdYX8m0f6Y" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:S+CL4A0RHlZrTQ41/nPePGlwVD4= In-Reply-To: <20240627202641.177@kylheku.com> Content-Language: en-GB Bytes: 3424 On 28/06/2024 04:30, Kaz Kylheku wrote: > On 2024-06-27, bart <bc@freeuk.com> wrote: >> For most, PIC isn't a necessity. > > Only because they use a virtual memory operating system which allows > every executable to be mapped to the same fixed address in its own > address space. PIC never seemed to be a requirement during the 1980s and half the 90s. But then OSes only ran one program a time. And when virtual addressing came along, and multiple programs could co-exist at the same address, PIC wasn't really needed either. > > If you designed your personal OS, which would be the case? > > [ ] Programs must be PIC > > [ ] Programs needn't be PIC With or without virtual addressing? On x64, there are several aspects to this: * Code that runs within the low 2GB (4GB is troublesome) * Code that runs above 2GB, so that 32-bit fields (often signed so that only 31 bits are usable) that refer to absolute addresses of code or data will need 33 bits or more * Dynamically linked /shared/ libraries, which need to have base-relocation tables (since you can't have multiple libraries all at the same address within the host process's virtual space), but which are not necessarily relocated above 2GB * True PIC that requires special compiler support (to avoid generating address modes that involve registers plus absolute 32-bit address offsets). RIP-relative address modes, when there are no registers, can be done with instruction encoding outside of the compiler It's all rather messy. I can generate true PIC if necessary (for OBJ files that might be linked with ld, or DLLs that /might/ be relocated above 2GB). But usually I generate code to load within the first 2GB.