# HG changeset patch # User Pascal Bellard # Date 1488885676 -3600 # Node ID 008ac2992c522d6dc46eb81768d437bdeafb15d5 # Parent 6f494adb2c71ff23cdf6abefe0fa07b259e89973 linld: remove dead code diff -r 6f494adb2c71 -r 008ac2992c52 linld/stuff/src/CRTL.ASM --- a/linld/stuff/src/CRTL.ASM Sun Mar 05 13:22:08 2017 +0100 +++ b/linld/stuff/src/CRTL.ASM Tue Mar 07 12:21:16 2017 +0100 @@ -51,18 +51,20 @@ ;char* strcat(const char* a, const char* b); ;char* strcatb(const char* a, const char* b); ;*************************************************************** - global _strcpy:near - proc _strcpy near + global _strcatb:near + proc _strcatb near - mov dl,0 + ifdef EXTRA + mov dl,3 db 0bbh ; mov bx,imm opcode global _strcat:near _strcat: mov dl,1 db 0bbh ; mov bx,imm opcode - global _strcatb:near -_strcatb: - mov dl,3 + global _strcpy:near +_strcpy: + mov dl,0 + endif pop ax ;caller return address pop cx ; a pop bx ; b @@ -71,15 +73,19 @@ push ax push si mov si,cx + ifdef EXTRA shr dl,1 jnc @@nocat + endif @@catlp: lodsb cmp al,0 jne @@catlp dec si + ifdef EXTRA shr dl,1 jnc @@nocat + endif cmp cx,si jz @@nocat mov [word si],20h @@ -96,7 +102,7 @@ pop si ret - endp _strcpy + endp _strcatb ;*************************************************************** @@ -159,6 +165,29 @@ endp _puts + ifdef EXTRA +;*************************************************************** +;int chdir(char *path); +;*************************************************************** + global _chdir:near + proc _chdir near + + pop ax + pop dx + push dx + push ax +chdir: + stc + mov ax,713Bh + int 21h + jnc chkc + mov ah,3Bh + jmp dos + + endp _chdir + endif + + ;*************************************************************** ;int fileattr(const char* name); ;*************************************************************** @@ -1352,30 +1381,6 @@ ;*************************************************************** -;int chdir(char *path); -;*************************************************************** - global _chdir:near - proc _chdir near - - pop ax - pop dx - push dx - push ax -chdir: - stc - mov ax,713Bh - int 21h - jnc @@end - mov ah,3Bh - int 21h -@@end: - sbb ax,ax - ret - - endp _chdir - - -;*************************************************************** ;int chdirname(char *path) ;*************************************************************** global _chdirname:near diff -r 6f494adb2c71 -r 008ac2992c52 linld/stuff/src/CRTL.H --- a/linld/stuff/src/CRTL.H Sun Mar 05 13:22:08 2017 +0100 +++ b/linld/stuff/src/CRTL.H Tue Mar 07 12:21:16 2017 +0100 @@ -25,11 +25,7 @@ extern char bss_start; extern char bss_end; extern char* heap_top; -extern int ximage_size, ximage_fd; - void parse_cmdline(); -extern "C" char* strcpy(const char* a,const char* b); -extern "C" char* strcat(const char* a,const char* b); extern "C" char* strcatb(const char* a,const char* b); extern "C" int strhead(const char* a,const char* b); extern "C" int fileattr(const char* name); @@ -46,10 +42,6 @@ extern "C" unsigned long strtol(const char *s); // Extensions -//static void barrier() {} -//static void cli() { asm { cli } } -//static void sti() { asm { sti } } -#define barrier() do {} while(0) #define cli() do { asm { cli } } while(0) #define sti() do { asm { sti } } while(0) #define int3() do { asm { db 0cch } } while(0) diff -r 6f494adb2c71 -r 008ac2992c52 linld/stuff/src/CRTLX.H --- a/linld/stuff/src/CRTLX.H Sun Mar 05 13:22:08 2017 +0100 +++ b/linld/stuff/src/CRTLX.H Tue Mar 07 12:21:16 2017 +0100 @@ -1,6 +1,8 @@ // This file is distributed under GPL // #define NULL 0 +extern "C" char* strcpy(const char* a,const char* b); +extern "C" char* strcat(const char* a,const char* b); extern "C" int strcmp(const char* a,const char* b); extern "C" int strlen(const char* s); extern "C" char* strstr(const char* a,const char* b); @@ -12,5 +14,5 @@ extern "C" void try_default_args(); extern "C" long lseekset(int fd, unsigned long sz); #define seekset(fd,sz) lseekset(fd,(unsigned long) sz) -extern long cpu_features; -#define cpuhaslm() (((char *)&cpu_features)[3]&(char)0x20) +extern char cpu_features[]; +#define cpuhaslm() (cpu_features[3]&0x20) diff -r 6f494adb2c71 -r 008ac2992c52 linld/stuff/src/ISO9660.CPP --- a/linld/stuff/src/ISO9660.CPP Sun Mar 05 13:22:08 2017 +0100 +++ b/linld/stuff/src/ISO9660.CPP Tue Mar 07 12:21:16 2017 +0100 @@ -5,13 +5,13 @@ #define SECTORSZ 2048 #define SECTORBITS 11 -static char buffer[SECTORSZ]; +static char buffer[SECTORSZ+512]; // RR overflow struct isostate isostate; static int readsector(const unsigned long *offset) { return (isolseek(offset) != -1 - && read(isostate.fd, buffer, SECTORSZ) == SECTORSZ); + && read(isostate.fd, buffer, sizeof(buffer)) >= SECTORSZ); } int isoreset(char *name) @@ -26,7 +26,7 @@ return -1; } x->dirofs = (* (unsigned long *) (buffer + 0x9E)) << SECTORBITS; - x->dirsize = * (unsigned long *) (buffer + 0xA6); + x->dirsize = filesize2dirsize(* (unsigned long *) (buffer + 0xA6)); return 0; } @@ -41,20 +41,20 @@ struct isostate *x=&isostate; if (restart) { - x->curpos = SECTORSZ; + x->curdirsize = x->dirsize; x->curdirofs = x->dirofs; - x->curdirsize = x->dirsize; + goto restarted; } if (x->curpos >= SECTORSZ || * (short *) (buffer + x->curpos) == 0) { - if (x->curdirsize < SECTORSZ) return -1; + if (x->curdirsize < DIRSECTORSZ) return -1; + restarted: readsector(&x->curdirofs); x->curdirofs += SECTORSZ; - x->curdirsize -= SECTORSZ; + x->curdirsize -= DIRSECTORSZ; x->curpos = 0; } p = buffer + x->curpos; - size = * (short *) p; - if (size == 0) + if ((size = * (short *) p) == 0) return -1; x->fileofs = (* (unsigned long *) (p + 2)) << SECTORBITS; x->filesize = * (unsigned long *) (p + 10); @@ -113,13 +113,12 @@ char _64bits = cpuhaslm(); struct isostate *x=&isostate; -retry32: + retry32: for (s = (char *) filename; *s == '/' ; s++) { isoreset(NULL); } next: - name = s; - do s++; while (*s && *s != '/'); + for (name = s; *s && *s != '/'; s++); c = *s; *s = 0; for (restart = 1; isoreaddir(restart) == 0; restart = 0) { @@ -133,7 +132,7 @@ *s++ = c; if (IS_DIR(x->filemod)) { x->dirofs = x->fileofs; - x->dirsize = x->filesize; + x->dirsize = filesize2dirsize(x->filesize); if (c) goto next; } isolseek(&x->fileofs); diff -r 6f494adb2c71 -r 008ac2992c52 linld/stuff/src/ISO9660.H --- a/linld/stuff/src/ISO9660.H Sun Mar 05 13:22:08 2017 +0100 +++ b/linld/stuff/src/ISO9660.H Tue Mar 07 12:21:16 2017 +0100 @@ -1,5 +1,11 @@ #ifndef __ISO9660_H #define __ISO9660_H +//typedef unsigned long dirsizetype; +//#define filesize2dirsize(x) (x) +//#define DIRSECTORSZ SECTORSZ +typedef unsigned dirsizetype; +#define filesize2dirsize(x) (*(unsigned *)((char *)&(x)+1)) +#define DIRSECTORSZ (SECTORSZ/256) extern struct isostate { int fd; unsigned long fileofs; @@ -7,8 +13,8 @@ unsigned short filemod; char *filename; //private - unsigned long dirofs, dirsize; - unsigned long curdirofs, curdirsize; + dirsizetype curdirsize, dirsize; + unsigned long curdirofs, dirofs; unsigned curpos; } isostate; #define isofd isostate.fd diff -r 6f494adb2c71 -r 008ac2992c52 linld/stuff/src/LINLD.CPP --- a/linld/stuff/src/LINLD.CPP Sun Mar 05 13:22:08 2017 +0100 +++ b/linld/stuff/src/LINLD.CPP Tue Mar 07 12:21:16 2017 +0100 @@ -35,7 +35,7 @@ ); } -static char _cmdline[256]; +static char _cmdline[128]; int main(int argc, char *argv[]) { (void) argc; @@ -112,12 +112,12 @@ topmem = strtol(s); goto addincmdline; } - else if(cmdline == (const char *) _cmdline) { + else if(cmdline == (const char *) _cmdline + 1) { addincmdline: strcatb(_cmdline,*argv); } else if(i == 1 && fileattr(s) != -1) { - cmdline = (const char *) _cmdline; + cmdline = (const char *) _cmdline + 1; goto set_kernel_name; } else