Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ jobs:
id: build
run: |
make deb
sudo dpkg -i ../dj64*.deb
sudo dpkg -i ../dj32*.deb
sudo dpkg -i ../dj64*.deb
sudo dpkg -i ../libdjdev64*.deb
sudo dpkg -i ../libdjstub64*.deb
sudo dpkg -i ../djdev64*.deb

- name: Upload failure logs
if: ${{ always() && (steps.build.outcome == 'failure') }}
Expand All @@ -40,4 +43,7 @@ jobs:
- name: Set up test environment
run: |
./ci_test_prereq.sh

- name: Run tests
run: |
./ci_test.sh
7 changes: 6 additions & 1 deletion ci_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

set -e -x

make demos -j 9
make demos_static
make -C demos run
make -C demos runelf
make demos_clean demos
make -C demos run
make -C demos runelf
cd demos/hello
ls -l hello
make host.elf
Expand Down
3 changes: 2 additions & 1 deletion ci_test_prereq.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

sudo add-apt-repository ppa:stsp-0/dj64
sudo add-apt-repository ppa:dosemu2/ppa
sudo apt install -y djstub dj64-host dos2unix
sudo add-apt-repository -y ppa:jwt27/djgpp-toolchain
sudo apt install -y djstub dj64-host dos2unix gcc-djgpp djgpp-dev
2 changes: 1 addition & 1 deletion demos/asmsimp/djgpp/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ info: $(TGT)
djstubify -i $<

run: $(TGT)
dosemu -t $<
dosemu -dumb $<

runelf: $(TGT)
djstubify $<
Expand Down
1 change: 1 addition & 0 deletions demos/asmsimp/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ run: $(TGT)

runelf: libtmp.so
dosemu -dumb -l $<
dosemu -dumb -l $< -g 1

# hook in dj64 - make sure to not do that before defining `all:` target
DJMK = $(shell pkg-config --silence-errors --variable=makeinc dj64)
Expand Down
2 changes: 1 addition & 1 deletion demos/file/32/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ info: $(TGT)
djstubify -i $<

run: $(TGT)
dosemu -t $<
dosemu -dumb $<

runelf: tmp.elf
dosemu -dumb -K . -E "elfexec2 $<"
Expand Down
2 changes: 1 addition & 1 deletion demos/file/djgpp/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ info: $(TGT)
djstubify -i $<

run: $(TGT)
dosemu -t $<
dosemu -dumb $<

runelf: $(TGT)
djstubify $<
Expand Down
4 changes: 2 additions & 2 deletions demos/file/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ int main()
puts("\n");
while (fgets(buf, sizeof(buf), f))
fputs(buf, stdout);
puts("\n\npress any key to exit");
getch();
// puts("\n\npress any key to exit");
// getch();
return EXIT_SUCCESS;
}
3 changes: 2 additions & 1 deletion demos/file/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ info: $(TGT)
djstubify -i $<

run: $(TGT)
dosemu -t $<
dosemu -dumb $<

runelf: libtmp.so
dosemu -dumb -K . -E "elfexec $<"
dosemu -dumb -K . -E "elfexec2 $<"

# hook in dj64 - make sure to not do that before defining `all:` target
DJMK = $(shell pkg-config --silence-errors --variable=makeinc dj64)
Expand Down
1 change: 1 addition & 0 deletions demos/hello/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ run: $(TGT)

runelf: libtmp.so
dosemu -dumb -l $<
dosemu -dumb -l $< -g 1

# hook in dj64 - make sure to not do that before defining `all:` target
DJMK = $(shell pkg-config --silence-errors --variable=makeinc dj64)
Expand Down
1 change: 1 addition & 0 deletions demos/helloasm/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ run: $(TGT)

runelf: libtmp.so
dosemu -dumb -l $<
dosemu -dumb -l $< -g 1

# hook in dj64 - make sure to not do that before defining `all:` target
DJMK = $(shell pkg-config --silence-errors --variable=makeinc dj64)
Expand Down
2 changes: 1 addition & 1 deletion demos/int86/32/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ info: $(TGT)
djstubify -i $<

run: $(TGT)
dosemu -t $<
dosemu -dumb $<

runelf: tmp.elf
dosemu -dumb -K . -E "elfexec2 $<"
Expand Down
2 changes: 1 addition & 1 deletion demos/int86/djgpp/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ info: $(TGT)
djstubify -i $<

run: $(TGT)
dosemu -t $<
dosemu -dumb $<

runelf: $(TGT)
djstubify $<
Expand Down
4 changes: 2 additions & 2 deletions demos/int86/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ int main()
sz = do_read(fd, buf, sizeof(buf));
if (sz > 0)
do_write(STDOUT_FILENO, buf, sz);
puts("\n\npress any key to exit");
getch();
// puts("\n\npress any key to exit");
// getch();
return EXIT_SUCCESS;
}
3 changes: 2 additions & 1 deletion demos/int86/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ info: $(TGT)
djstubify -i $<

run: $(TGT)
dosemu -t $<
dosemu -dumb $<

runelf: libtmp.so
dosemu -dumb -K . -E "elfexec $<"
dosemu -dumb -K . -E "elfexec2 $<"

# hook in dj64 - make sure to not do that before defining `all:` target
DJMK = $(shell pkg-config --silence-errors --variable=makeinc dj64)
Expand Down
6 changes: 3 additions & 3 deletions demos/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ clean:
$(foreach D,$(DEMOS),$(MAKE) -C $(D)/32 clean;)

run runelf:
$(foreach D,$(DEMOS),$(MAKE) -C $(D) $@;)
$(foreach D,$(DEMOS),$(MAKE) -C $(D)/32 $@;)
$(foreach D,$(DEMOS),$(MAKE) -C $(D)/djgpp $@;)
set -e; $(foreach D,$(DEMOS),$(MAKE) -C $(D) $@;)
set -e; $(foreach D,$(DEMOS),$(MAKE) -C $(D)/32 $@;)
set -e; $(foreach D,$(DEMOS),$(MAKE) -C $(D)/djgpp $@;)

rwildcard=$(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(subst *,%,$2),$d))

Expand Down
8 changes: 5 additions & 3 deletions demos/rmcb/32/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ clean: clean_dj32
info: $(TGT)
djstubify -i $<

run: $(TGT)
run:
runi: $(TGT)
dosemu -t $<

runelf: tmp.elf
dosemu -dumb -l $< -g 1
runelf:
runelfi: tmp.elf
dosemu -t -l $< -g 1

# hook in dj64 - make sure to not do that before defining `all:` target
DJMK = $(shell pkg-config --silence-errors --variable=makeinc dj32)
Expand Down
8 changes: 5 additions & 3 deletions demos/rmcb/djgpp/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ clean:
info: $(TGT)
djstubify -i $<

run: $(TGT)
run:
runi: $(TGT)
dosemu -t $<

runelf: $(TGT)
runelf:
runelfi: $(TGT)
djstubify $<
dosemu -dumb $<
dosemu -t $<
8 changes: 5 additions & 3 deletions demos/rmcb/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ clean: clean_dj64
info: $(TGT)
djstubify -i $<

run: $(TGT)
run:
runi: $(TGT)
dosemu -t $<

runelf: libtmp.so
dosemu -dumb -l $<
runelf:
runelfi: libtmp.so
dosemu -t -l $<

# hook in dj64 - make sure to not do that before defining `all:` target
DJMK = $(shell pkg-config --silence-errors --variable=makeinc dj64)
Expand Down
51 changes: 17 additions & 34 deletions src/djdev64/stub/stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,29 @@

#define STUB_DEBUG 1
#if STUB_DEBUG
#define stub_debug(...) J_printf(do_printf, DJ64_PRINT_LOG, __VA_ARGS__)
#define stub_debug(f, ...) J_printf(do_printf, DJ64_PRINT_LOG, "stub: " f, ##__VA_ARGS__)
#else
#define stub_debug(...)
#endif

#define FLG1_OFF STFLAGS_OFF
#define FLG2_OFF (STFLAGS_OFF + 1)

#define STFLG1_COMPACT 0x20 // compact 32bit VA layout
#define STFLG1_rsv2 0x20 // compact 32bit VA layout - pre-v7 stubs
#define STFLG1_STATIC SIFLG_STATIC // 0x40 - static linking
/* 2 flags below are chosen for compatibility between v4 and v5 stubs.
* They can't be set together, and as such, when we have a core payload,
* there is no indication of whether or not the user payload is also
* present. */
#define STFLG1_NO32PL 0x80 // no 32bit payload
#define STFLG1_rsv 0x80 // no 32bit payload - pre-v7 stubs
#define STFLG2_DJ32 0x20 // dj32 payload
#define STFLG2_C32PL 0x40 // have core 32bit payload
#define STFLG2_EMBOV 0x80 // embedded overlay layout

#define HAS_32PL(buf) (buf[FLG2_OFF] & STFLG2_EMBOV)

static const int STFLAGS_OFF = 0x38;

#define MB (1024 * 1024)
#define VA_SZ (2*MB)

Expand Down Expand Up @@ -221,8 +225,6 @@ int djstub_main(int argc, char *argv[], char *envp[],
_GO32_StubInfo stubinfo = {0};
_GO32_StubInfo *stubinfo_p;
struct ldops *ops = NULL;
int STFLAGS_OFF = 0x2c;
int compact_va = 0;
int dj32 = 0;
struct dos_ops *ioops = dosops;
uint8_t stub_ver = 0;
Expand Down Expand Up @@ -353,8 +355,6 @@ int djstub_main(int argc, char *argv[], char *envp[],
cnt++;
#endif
stubinfo.stubinfo_ver |= stub_ver << 16;
if (stub_ver >= 6)
STFLAGS_OFF = 0x38;
if (stub_ver >= 7)
stubinfo.flags |= SIFLG_SPLITPL;
stub_debug("Found exe header %i at 0x%lx\n", cnt, coffset);
Expand All @@ -365,28 +365,14 @@ int djstub_main(int argc, char *argv[], char *envp[],
pfile = ifile;
if (stub_ver >= 7 && dyn)
moff = 4;
if (buf[FLG1_OFF] & STFLG1_NO32PL) {
noffset = offs;
moff = 4;
done = 1;
assert(dyn);
OPEN_DYN();
} else {
pl32++;
coffset = offs;
if (stub_ver == 6) {
/* static crt0 in emb_ov - deprecated */
uint32_t ooffs;
memcpy(&ooffs, &buf[0x2c], sizeof(ooffs));
coffset += ooffs;
}
coffset = offs;
noffset = offs;
if (stub_ver >= 7 && !dyn) {
memcpy(&coffsize, &buf[0x1c], sizeof(coffsize));
noffset = offs;
if ((stub_ver >= 7 && !dyn) || !(buf[FLG2_OFF] & STFLG2_EMBOV))
noffset += coffsize;
noffset += coffsize;
}
if (buf[FLG1_OFF] & STFLG1_COMPACT)
compact_va = 1;
if (HAS_32PL(buf))
pl32++;
if (buf[FLG2_OFF] & STFLG2_DJ32) {
done = 1;
dj32 = 1;
Expand Down Expand Up @@ -429,8 +415,7 @@ int djstub_main(int argc, char *argv[], char *envp[],
if (is_64) {
dyn++;
OPEN_DYN();
compact_va = 1; // TODO - evaluate?
stubinfo.flags = ((STFLG2_EMBOV) << 8) | STFLG1_COMPACT;
stubinfo.flags = (STFLG2_EMBOV) << 8;
stubinfo.flags |= SHM_FLAGS;
nsize = dosops->_dos_seek(ifile, 0, SEEK_END);
} else {
Expand All @@ -443,9 +428,7 @@ int djstub_main(int argc, char *argv[], char *envp[],
} else if (is_64 && (stub_ver < 7 || !dyn)) {
error("djstub: 64bit ELF at position %lx\n", coffset);
return -1;
} else if (dyn) {
OPEN_DYN();
} else {
} else if (!dyn) {
ops = &elf_ops;
}
done = 1;
Expand All @@ -455,7 +438,7 @@ int djstub_main(int argc, char *argv[], char *envp[],
}
dosops->_dos_seek(ifile, coffset, SEEK_SET);
}
if (dyn && !pl32 && coffset)
if (dyn && coffset)
OPEN_DYN();
assert(ops);
assert(pfile != -1);
Expand Down Expand Up @@ -516,7 +499,7 @@ int djstub_main(int argc, char *argv[], char *envp[],
if (!dj32 && va_size > MB)
exit(EXIT_FAILURE);
/* if we load 2 payloads, use larger estimate */
if ((dyn && pl32) || compact_va) {
if (pl32) {
stubinfo.initial_size = VA_SZ;
stubinfo.upl_base = va;
stubinfo.upl_size = VA_SZ;
Expand Down
Loading