News for hackers. Stuff that matters.
Re:Dynamic linking by spc476 on Saturday June 27, 2020 @04:52AM (#23660442)
When I participated in NaNoGenMo 2015 [1], I ended up having to emulate a very small subset of MS-DOS [2]. That meant loading in an MS-DOS `.EXE` file into memory and running it. I had a 32-bit Linux system, so I was able to use the `vm86()` system call to run the 16-bit code natively. The `.EXE` file had basically two sections---the first the actual binary code (and data and what have you). This was followed by another section that contained offsets into the code that was loaded that needed to be updated with the proper address, and it took all of five lines of code to implement [3]. Once used, that segment can be discarded. You don't need position independent code to implement address space layout randomization (it makes it easier), you just need a table to rework the absolute addresses (downside---it may take some time).

[1] National Novel Generation Month

[2] https://github.com/spc476/NaNoGenMo-2015, specifically, https://github.com/spc476/NaNoGenMo-2015/blob/master/C/msdos...

[3] lines 337 to 343 of `msdos.c` [2]

Re:Dynamic linking by saagarjha on Saturday June 27, 2020 @05:22AM (#23660545)
This isn’t my area of expertise, but I think on Windows relocations are actually handled quite similarly (as a table of locations that the loader uses to patch with).
Re:Dynamic linking by account42 on Monday June 29, 2020 @08:19AM (#23676882)
Relocation by patching code means you no can no longer share code sections between programs.