summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* elf2exe: when adding the 32-bit relocation stub, check the stackHEADmasterH. Peter Anvin2019-08-052-19/+72
| | | | | | | | | | | | | When adding the 32-bit relocation stub, we might end up overlapping the intended stack segment. In that case, set up a temporary stack just beyond the end of the relocation data, and possibly adjust the memory sizes accordingly. Move the memory size calculations down and make them uniformly addresses, not incremental numbers, as it turns out subtraction at the end is way easier in the end. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* elf2exe: use putle() when updating cs:ip for the relocator stubH. Peter Anvin2019-08-051-4/+4
| | | | | | CS:IP in the relocator stub are littleendian values, too. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* elf2exe: verify limit on 32-bit relocationsH. Peter Anvin2019-08-051-0/+7
| | | | | | | | | Verify that the stub and the 32-bit relocations fit in a 64K segment. If that isn't the case, one probably needs to do more complex stuff such as reading the ELF file in protected mode, like DJGPP does with COFF. This still corresponds to 16,367 possible relocations. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* elf2exe: sort relocationsH. Peter Anvin2019-08-051-0/+14
| | | | | | | | The linker probably already did, but just in case, sort the relocations, for predictability and possibly for loader optimization/simplification. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* macros.hs: add convenience define global macroH. Peter Anvin2019-08-021-0/+6
|
* Move macro package to its own file, macros.hs. It is generic.H. Peter Anvin2019-08-023-62/+78
| | | | | Move the macro package to a header file; it is intended to be usabe in general code.
* macros.s: handle HUGE sectionsH. Peter Anvin2019-08-022-17/+69
| | | | | | Support HUGE sections, via a s.huge declaration macro (like s.group). Add a directive s.huge which declares an upcoming section as HUGE.
* With my most recent patch, gas can now generate SEG16 relocationsH. Peter Anvin2019-07-293-12/+29
| | | | Switch to @SEG syntax, removing the first set of .reloc hacks.
* rel32.asm: don't bother supporting more than 16,367 relocationsH. Peter Anvin2019-07-291-0/+5
| | | | | | | | | | We can save 9 bytes if the relocation count is limited to 16,367 which is very likely to be the case (that's 64K of memory just containing relocatable values!) If we have more than that we are probably doing something involving extended memory and we should do this in protected mode anyway. See: DJGPP.
* rel32.asm: make smaller by using MULH. Peter Anvin2019-07-291-12/+3
|
* Fix the computation optional memory requestedH. Peter Anvin2019-07-292-4/+8
|
* exe.ld: allow programs to request optional memoryH. Peter Anvin2019-07-291-13/+18
| | | | | Adding things to this section will ask for optional memory in the EXE header.
* Makefile: make debugging easier by omitting not-taken conditionalsH. Peter Anvin2019-07-291-1/+1
| | | | | It gets easier to follow which paths we take if we don't have to see the not-taken conditionals.
* macros.s: show how macros can be used to implement most thingsH. Peter Anvin2019-07-282-2/+124
| | | | Simple macros which can take care of most of the weirdness.
* testme.s: add a far text function for testingH. Peter Anvin2019-07-281-3/+18
|
* elf2exe: support generating a relocation stub if necessaryH. Peter Anvin2019-07-284-72/+139
| | | | | | | If 32-bit linear relocations are present, automatically generate a relocation stub. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* elf2exe: fix computation of bssmemH. Peter Anvin2019-07-281-5/+9
|
* rel32.asm: add missing pop axH. Peter Anvin2019-07-281-0/+1
| | | | If we push it, we have to pop it...
* Makefile: build rel32.bin and convert it to a C fileH. Peter Anvin2019-07-283-3/+21
|
* elf2exe: relocation stub for 32-bit absolute relocations (currently unused)H. Peter Anvin2019-07-281-0/+89
| | | | | Relocation stub which we could use to fix up 32-bit linear address relocations (R_386_RELATIVE).
* file.c: don't lose READ_FILE on mmap failureH. Peter Anvin2019-07-281-4/+9
| | | | | | Losing READ_FILE causes map_file_stdio() to think we are writing. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* file.c: fix writing to a non-mappable fileH. Peter Anvin2019-07-281-3/+3
| | | | | | | Correctly handle the case where the output file can't be mapped and we need to fall back to stdio. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* Makefile: change from -O0 to -O2H. Peter Anvin2019-07-281-1/+1
| | | | | | -O0 was a temporary hack for debugging. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* elf2exe: working elf2exe programH. Peter Anvin2019-07-288-0/+1165
| | | | | | | This file can now convert a PIE ELF binary to EXE, as long as the only relocations present are the ones supported. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* testme.s: don't generate a non-EXE-able relocationH. Peter Anvin2019-07-281-1/+1
| | | | | | Going to actually convert to EXE next... Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* exe.ld: don't pick up relocation sections prematurelyH. Peter Anvin2019-07-281-12/+8
| | | | | | | ?*_TEXT etc would pick up .rel_TEXT etc. Have these patterns not match a leading dot. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* Makefile: link in psp.oH. Peter Anvin2019-07-281-1/+2
|
* Move PSP to -256, add PSP object, note that -q is only for debuggingH. Peter Anvin2019-07-271-0/+7
| | | | | | | | | | | Update to my binutils tree now handles R_386_SEG16 to a negative offset correctly, so the PSP can be moved to the correct address of -256. Add a separate object file for the PSP; this would normally be part of the runtime library if needed. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* exe.ld: clean up and fix the dynamic tagsH. Peter Anvin2019-07-271-18/+12
|
* com.ld: clean up indentationH. Peter Anvin2019-07-271-23/+23
|
* exe.ld: clean up indentationH. Peter Anvin2019-07-271-66/+71
|
* Use dynamic tags from the OS-specific space for additional infoH. Peter Anvin2019-07-273-22/+60
|
* Add size checks, explain the nature of ___stack_size in .comH. Peter Anvin2019-07-272-11/+12
|
* Make -pie linking actually work; use ___start for initial symbolH. Peter Anvin2019-07-274-20/+47
|
* Set OUTPUT_ARCH to i8086, even though it doesn't seem to change anythingH. Peter Anvin2019-07-272-2/+2
|
* .gitignore: a few more patternsH. Peter Anvin2019-07-271-0/+7
|
* exe.ld: document why PSP is at 0xfff00 instead of -256H. Peter Anvin2019-07-271-0/+8
|
* Produce actual .com files and add support for producing .exe filesH. Peter Anvin2019-07-271-3/+11
| | | | | | This is actually bogus: .com files (tiny model) generally needs different source code from .exe files (small, medium, compact, large, huge models.)
* Makefile: don't delete files; no implict rules; fix .s -> .o ruleH. Peter Anvin2019-07-271-1/+7
|
* Makefile: add make spotlessH. Peter Anvin2019-07-271-0/+3
|
* Some initial sample codeH. Peter Anvin2019-07-275-0/+348