position independent code
position independent code
djgpp is not sopporting -pie or position independent code.
is there any way to make it support.
is there any way to make it support.
- Brynet-Inc
- Member
- Posts: 2426
- Joined: Tue Oct 17, 2006 9:29 pm
- Libera.chat IRC: brynet
- Location: Canada
- Contact:
Re: position independent code
DJGPP == DOS compiler suite.
I'm going to out on a limb and say that DOS does not support position independent code or executables.
I'm going to out on a limb and say that DOS does not support position independent code or executables.
Re: position independent code
Probably not. Compile a cross compiler. See the wiki for instructions.
Is DJGPP a version of GCC? If not, you'll need to get one before you can make your cross compiler.
Is DJGPP a version of GCC? If not, you'll need to get one before you can make your cross compiler.
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: position independent code
DJGPP is GCC for DOS.
But really, you do not want to make a cross-compiler using DJGPP. You'd end up coming across about each and every bad aspect of DOS you can imagine. And besides, DJGPP itself is dated and slightly buggy.
So I repeat:
You do not want to use DJGPP </jedi mind trick>
But really, you do not want to make a cross-compiler using DJGPP. You'd end up coming across about each and every bad aspect of DOS you can imagine. And besides, DJGPP itself is dated and slightly buggy.
So I repeat:
You do not want to use DJGPP </jedi mind trick>
Re: position independent code
I do.</Jabba the Hutt>Combuster wrote:So I repeat:
You do not want to use DJGPP </jedi mind trick>
Re: position independent code
Well, COM-files were entirely position independent, as everything resided within a single segment. EXE-files, being multi-segmented, needed fixing at load time, but the file format itself could be called position independent. So unless that's not what you meant, I have to disagree.Brynet-Inc wrote:I'm going to out on a limb and say that DOS does not support position independent code or executables.
JAL
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: position independent code
How is using CS/DS instead of EBX less position independent than 32-bits PIC?berkus wrote:Addresses within a segment are always 0-based. How is that position independent?
Re: position independent code
Indeed. Segmentation can be considered position independence, albeit with a 16 byte granularity in real mode. Additionally, using segment registers saves a general purpose register of which the x86 doesn't have that many. No global offset table needed either.
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: position independent code
So? DOS apps toss segment registers around all the time - it may be old but it's not stupid enough to limit itself to 64K code/data.
Better argument please.
Better argument please.
- Brynet-Inc
- Member
- Posts: 2426
- Joined: Tue Oct 17, 2006 9:29 pm
- Libera.chat IRC: brynet
- Location: Canada
- Contact:
Re: position independent code
Some alien bastard broke the tree limb I was standing on, but anyway, it seems DJGPP generates executables that don't run natively on DOS but using a 32-bit DOS extender, which itself may not have a realization of PIC/PIE and hence is a compiler feature NOP.
None of this is overly interesting anyway, it's all about some new user (..who's probably gone) and their attempt to wrangle a DOS compiler for OSDev.
None of this is overly interesting anyway, it's all about some new user (..who's probably gone) and their attempt to wrangle a DOS compiler for OSDev.
Re: position independent code
This is exactly what makes an offset table unnecessary.berkus wrote:Because you need different values of CS/DS when addressing this code/data, meaning you cannot simply mix several code modules without changing CS/DS whilst calling them.
Re: position independent code
Segmentation means position indepedent. All my device-drivers are position independent, and also require no relocations. This is because the linker takes the code and data selector as an input, replacing all references to code and data segments with one of these selectors. This means a device-driver can be loaded at any linear address. And segments can be 16-bit or 32-bit, so there is no size limits to this concept either.
Re: position independent code
There is no need to have many different code modules in the same device in a segmented OS. It is when one device calls another that far pointers are needed, otherwise a near model works perfectly well. Just forget about the useless far memory models of old DOS. This was invented because of 16-bit limitations in DOS (and the 286), and should not be used in a segmented OS that can define segments as 32-bit if needed.berkus wrote:Because you need different values of CS/DS when addressing this code/data, meaning you cannot simply mix several code modules without changing CS/DS whilst calling them.