Giter Site home page Giter Site logo

ELF Loader Implementation about orion HOT 15 OPEN

vmlemon avatar vmlemon commented on July 23, 2024
ELF Loader Implementation

from orion.

Comments (15)

vmlemon avatar vmlemon commented on July 23, 2024

For testing, I imported https://hg.icculus.org/icculus/mojoelf/file/78de07f0b181

from orion.

vmlemon avatar vmlemon commented on July 23, 2024

After adding more types, that code gets to:

tyson@tyson-Lenovo-ideapad-120S-14IAP:~/Orion/user/apps/system$ make
===> mojoelf.c
gcc-6 -I../../include -I../.. -I/usr/lib/gcc/x86_64-linux-gnu/6/include   -nostdinc -g -O2 -m64 -mno-red-zone   -fno-stack-protector -lssp -O2 -g -Wall -Wshadow   -fno-stack-protector  -Wconversion -std=c99 -c mojoelf.c -o mojoelf.o
In file included from mojoelf.c:9:0:
../../include/stdio.h: In function ‘__sputc’:
../../include/stdio.h:460:23: warning: conversion to ‘unsigned char’ from ‘int’ may alter its value [-Wconversion]
   return (*_p->_p++ = _c);
                       ^~
In file included from mojoelf.c:16:0:
../../include/sys/types.h: In function ‘__bitcount16’:
../../include/sys/types.h:327:7: warning: conversion to ‘__uint16_t {aka short unsigned int}’ from ‘int’ may alter its value [-Wconversion]
  _x = (_x & 0x5555) + ((_x & 0xaaaa) >> 1);
       ^
../../include/sys/types.h:328:7: warning: conversion to ‘__uint16_t {aka short unsigned int}’ from ‘int’ may alter its value [-Wconversion]
  _x = (_x & 0x3333) + ((_x & 0xcccc) >> 2);
       ^
In file included from ../../include/sys/types.h:376:0,
                 from mojoelf.c:16:
../../include/sys/select.h: At top level:
../../include/sys/select.h:105:54: warning: ‘struct timeval’ declared inside parameter list will not be visible outside of this definition or declaration
 int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
                                                      ^~~~~~~
In file included from mojoelf.c:16:0:
../../include/sys/types.h: In function ‘__major’:
../../include/sys/types.h:393:36: warning: conversion to ‘int’ from ‘dev_t {aka long unsigned int}’ may alter its value [-Wconversion]
  return (((_d >> 32) & 0xffffff00) | ((_d >> 8) & 0xff));
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
../../include/sys/types.h: In function ‘__minor’:
../../include/sys/types.h:399:32: warning: conversion to ‘int’ from ‘dev_t {aka long unsigned int}’ may alter its value [-Wconversion]
  return (((_d >> 24) & 0xff00) | (_d & 0xffff00ff));
         ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
../../include/sys/types.h: In function ‘__makedev’:
../../include/sys/types.h:405:26: warning: conversion to ‘unsigned int’ from ‘int’ may change the sign of the result [-Wsign-conversion]
  return (((dev_t)(_Major & 0xffffff00) << 32) | ((_Major & 0xff) << 8) |
                          ^
../../include/sys/types.h:405:47: warning: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Wsign-conversion]
  return (((dev_t)(_Major & 0xffffff00) << 32) | ((_Major & 0xff) << 8) |
                                               ^
../../include/sys/types.h:406:49: warning: conversion to ‘unsigned int’ from ‘int’ may change the sign of the result [-Wsign-conversion]
      ((dev_t)(_Minor & 0xff00) << 24) | (_Minor & 0xffff00ff));
                                                 ^
mojoelf.c: In function ‘Malloc’:
mojoelf.c:375:20: warning: implicit declaration of function ‘calloc’ [-Wimplicit-function-declaration]
     void *retval = calloc(1, len);
                    ^~~~~~
mojoelf.c:375:20: warning: incompatible implicit declaration of built-in function ‘calloc’
mojoelf.c:375:20: note: include ‘<stdlib.h>’ or provide a declaration of ‘calloc’
mojoelf.c: In function ‘validate_elf_header’:
mojoelf.c:453:28: warning: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Wsign-conversion]
     else if ((hdr->e_phoff + (hdr->e_phnum * hdr->e_phentsize)) > ctx->buflen)
                            ^
mojoelf.c:455:28: warning: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Wsign-conversion]
     else if ((hdr->e_shoff + (hdr->e_shnum * hdr->e_shentsize)) > ctx->buflen)
                            ^
mojoelf.c: In function ‘process_program_headers’:
mojoelf.c:521:32: warning: conversion to ‘int’ from ‘long unsigned int’ may alter its value [-Wconversion]
             ctx->dyntabcount = (program->p_filesz / sizeof (ElfDynTable));
                                ^
mojoelf.c: In function ‘process_section_headers’:
mojoelf.c:565:32: warning: conversion to ‘int’ from ‘long unsigned int’ may alter its value [-Wconversion]
             ctx->symtabcount = section->sh_size / MOJOELF_SIZEOF_SYMENT;
                                ^~~~~~~
mojoelf.c: In function ‘map_pages’:
mojoelf.c:301:26: warning: implicit declaration of function ‘memset’ [-Wimplicit-function-declaration]
 #define Memzero(buf,len) memset(buf, '\0', len)
                          ^
mojoelf.c:596:5: note: in expansion of macro ‘Memzero’
     Memzero(mmapaddr, mmaplen);
     ^~~~~~~
mojoelf.c:301:26: warning: incompatible implicit declaration of built-in function ‘memset’
 #define Memzero(buf,len) memset(buf, '\0', len)
                          ^
mojoelf.c:596:5: note: in expansion of macro ‘Memzero’
     Memzero(mmapaddr, mmaplen);
     ^~~~~~~
mojoelf.c:301:26: note: include ‘<string.h>’ or provide a declaration of ‘memset’
 #define Memzero(buf,len) memset(buf, '\0', len)
                          ^
mojoelf.c:596:5: note: in expansion of macro ‘Memzero’
     Memzero(mmapaddr, mmaplen);
     ^~~~~~~
mojoelf.c:302:30: warning: implicit declaration of function ‘memcpy’ [-Wimplicit-function-declaration]
 #define Memcopy(dst,src,len) memcpy(dst,src,len)
                              ^
mojoelf.c:606:13: note: in expansion of macro ‘Memcopy’
             Memcopy(ptr, ctx->buf + program->p_offset, program->p_filesz);
             ^~~~~~~
mojoelf.c:302:30: warning: incompatible implicit declaration of built-in function ‘memcpy’
 #define Memcopy(dst,src,len) memcpy(dst,src,len)
                              ^
mojoelf.c:606:13: note: in expansion of macro ‘Memcopy’
             Memcopy(ptr, ctx->buf + program->p_offset, program->p_filesz);
             ^~~~~~~
mojoelf.c:302:30: note: include ‘<string.h>’ or provide a declaration of ‘memcpy’
 #define Memcopy(dst,src,len) memcpy(dst,src,len)
                              ^
mojoelf.c:606:13: note: in expansion of macro ‘Memcopy’
             Memcopy(ptr, ctx->buf + program->p_offset, program->p_filesz);
             ^~~~~~~
mojoelf.c: In function ‘load_external_dependencies’:
mojoelf.c:837:72: warning: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Wsign-conversion]
     ctx->retval->dlopens = (void **) Malloc(ctx->retval->dlopens_count * sizeof (void *));
                                                                        ^
mojoelf.c:866:5: warning: implicit declaration of function ‘assert’ [-Wimplicit-function-declaration]
     assert(0);
     ^~~~~~
mojoelf.c: In function ‘do_fixup’:
mojoelf.c:942:13: warning: incompatible implicit declaration of built-in function ‘memcpy’
             memcpy(fixup, (void *) addr, (ctx->symtab+r_sym)->st_size);
             ^~~~~~
mojoelf.c:942:13: note: include ‘<string.h>’ or provide a declaration of ‘memcpy’
mojoelf.c:952:39: warning: conversion to ‘long unsigned int’ from ‘intptr {aka const long int}’ may change the sign of the result [-Wsign-conversion]
             *fixup += (uintptr) (addr + r_addend);
                                       ^
mojoelf.c:955:40: warning: conversion to ‘long unsigned int’ from ‘intptr {aka const long int}’ may change the sign of the result [-Wsign-conversion]
             *fixup += (uintptr) ((addr + r_addend) - ((uintptr) fixup));
                                        ^
mojoelf.c: In function ‘add_exported_symbol’:
mojoelf.c:1057:44: warning: implicit declaration of function ‘strlen’ [-Wimplicit-function-declaration]
     syms[syms_count].sym = (char *) Malloc(strlen(sym) + 1);
                                            ^~~~~~
mojoelf.c:1057:44: warning: incompatible implicit declaration of built-in function ‘strlen’
mojoelf.c:1057:44: note: include ‘<string.h>’ or provide a declaration of ‘strlen’
mojoelf.c:300:21: warning: implicit declaration of function ‘strcpy’ [-Wimplicit-function-declaration]
 #define Strcpy(a,b) strcpy(a,b)
                     ^
mojoelf.c:1061:5: note: in expansion of macro ‘Strcpy’
     Strcpy(syms[syms_count].sym, sym);
     ^~~~~~
mojoelf.c:300:21: warning: incompatible implicit declaration of built-in function ‘strcpy’
 #define Strcpy(a,b) strcpy(a,b)
                     ^
mojoelf.c:1061:5: note: in expansion of macro ‘Strcpy’
     Strcpy(syms[syms_count].sym, sym);
     ^~~~~~
mojoelf.c:300:21: note: include ‘<string.h>’ or provide a declaration of ‘strcpy’
 #define Strcpy(a,b) strcpy(a,b)
                     ^
mojoelf.c:1061:5: note: in expansion of macro ‘Strcpy’
     Strcpy(syms[syms_count].sym, sym);
     ^~~~~~
mojoelf.c: In function ‘build_export_list’:
mojoelf.c:1101:67: warning: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Wsign-conversion]
     ctx->retval->syms = (ElfSymbols *) Malloc(sizeof (ElfSymbols) * symcount);
                                                                   ^
mojoelf.c: In function ‘MOJOELF_dlopen_mem’:
mojoelf.c:301:26: warning: incompatible implicit declaration of built-in function ‘memset’
 #define Memzero(buf,len) memset(buf, '\0', len)
                          ^
mojoelf.c:1168:5: note: in expansion of macro ‘Memzero’
     Memzero(&ctx, sizeof (ElfContext));
     ^~~~~~~
mojoelf.c:301:26: note: include ‘<string.h>’ or provide a declaration of ‘memset’
 #define Memzero(buf,len) memset(buf, '\0', len)
                          ^
mojoelf.c:1168:5: note: in expansion of macro ‘Memzero’
     Memzero(&ctx, sizeof (ElfContext));
     ^~~~~~~
mojoelf.c: In function ‘MOJOELF_dlsym’:
mojoelf.c:299:21: warning: implicit declaration of function ‘strcmp’ [-Wimplicit-function-declaration]
 #define Strcmp(a,b) strcmp(a,b)
                     ^
mojoelf.c:1216:13: note: in expansion of macro ‘Strcmp’
         if (Strcmp(h->syms[i].sym, sym) == 0)
             ^~~~~~
mojoelf.c: In function ‘MOJOELF_dlclose’:
mojoelf.c:1250:9: warning: implicit declaration of function ‘free’ [-Wimplicit-function-declaration]
         free(h->dlopens);
         ^~~~
mojoelf.c:1250:9: warning: incompatible implicit declaration of built-in function ‘free’
mojoelf.c:1250:9: note: include ‘<stdlib.h>’ or provide a declaration of ‘free’
mojoelf.c:1259:13: warning: incompatible implicit declaration of built-in function ‘free’
             free(h->syms[i].sym);
             ^~~~
mojoelf.c:1259:13: note: include ‘<stdlib.h>’ or provide a declaration of ‘free’
mojoelf.c:1260:9: warning: incompatible implicit declaration of built-in function ‘free’
         free(h->syms);
         ^~~~
mojoelf.c:1260:9: note: include ‘<stdlib.h>’ or provide a declaration of ‘free’
mojoelf.c:1263:5: warning: incompatible implicit declaration of built-in function ‘free’
     free(h);
     ^~~~
mojoelf.c:1263:5: note: include ‘<stdlib.h>’ or provide a declaration of ‘free’
mojoelf.c: In function ‘MOJOELF_dlopen_file’:
mojoelf.c:1276:21: warning: implicit declaration of function ‘strerror’ [-Wimplicit-function-declaration]
         set_dlerror(strerror(errno));
                     ^~~~~~~~
mojoelf.c:1276:21: warning: passing argument 1 of ‘set_dlerror’ makes pointer from integer without a cast [-Wint-conversion]
mojoelf.c:135:24: note: expected ‘const char *’ but argument is of type ‘int’
     static inline void set_dlerror(const char *msg) { dlerror_msg = msg; }
                        ^~~~~~~~~~~
mojoelf.c:1278:21: warning: passing argument 1 of ‘set_dlerror’ makes pointer from integer without a cast [-Wint-conversion]
         set_dlerror(strerror(errno));
                     ^~~~~~~~
mojoelf.c:135:24: note: expected ‘const char *’ but argument is of type ‘int’
     static inline void set_dlerror(const char *msg) { dlerror_msg = msg; }
                        ^~~~~~~~~~~
mojoelf.c:1279:31: warning: implicit declaration of function ‘malloc’ [-Wimplicit-function-declaration]
     else if ((buf = (uint8 *) malloc(statbuf.st_size)) == NULL)
                               ^~~~~~
mojoelf.c:1279:31: warning: incompatible implicit declaration of built-in function ‘malloc’
mojoelf.c:1279:31: note: include ‘<stdlib.h>’ or provide a declaration of ‘malloc’
mojoelf.c:1279:38: warning: conversion to ‘long unsigned int’ from ‘off_t {aka long int}’ may change the sign of the result [-Wsign-conversion]
     else if ((buf = (uint8 *) malloc(statbuf.st_size)) == NULL)
                                      ^~~~~~~
mojoelf.c:1281:14: warning: implicit declaration of function ‘read’ [-Wimplicit-function-declaration]
     else if (read(fd, buf, statbuf.st_size) != statbuf.st_size)
              ^~~~
mojoelf.c:1282:21: warning: passing argument 1 of ‘set_dlerror’ makes pointer from integer without a cast [-Wint-conversion]
         set_dlerror(strerror(errno));
                     ^~~~~~~~
mojoelf.c:135:24: note: expected ‘const char *’ but argument is of type ‘int’
     static inline void set_dlerror(const char *msg) { dlerror_msg = msg; }
                        ^~~~~~~~~~~
mojoelf.c:1285:9: warning: implicit declaration of function ‘close’ [-Wimplicit-function-declaration]
         close(fd);
         ^~~~~
mojoelf.c:1294:9: warning: incompatible implicit declaration of built-in function ‘free’
         free(buf);
         ^~~~
mojoelf.c:1294:9: note: include ‘<stdlib.h>’ or provide a declaration of ‘free’
===> Linking ./syslaunch
ld -e_start -N -L../../lib -L/usr/lib/gcc/x86_64-linux-gnu/6 -nostdlib  -melf_x86_64  -Ttext=01000000 crt0-amd64.o syslaunch.o mojoelf.o    -ll4 -lio  -llinux  -lgcc -o syslaunch
ld: mojoelf.o: in function `MOJOELF_dlsym':
/home/tyson/Orion/user/apps/system/mojoelf.c:1216: undefined reference to `strcmp'
ld: mojoelf.o: in function `do_fixup':
/home/tyson/Orion/user/apps/system/mojoelf.c:942: undefined reference to `memcpy'
ld: mojoelf.o: in function `MOJOELF_dlclose':
/home/tyson/Orion/user/apps/system/mojoelf.c:1250: undefined reference to `free'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1254: undefined reference to `munmap'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1259: undefined reference to `free'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1260: undefined reference to `free'
ld: mojoelf.o: in function `MOJOELF_dlopen_mem':
/home/tyson/Orion/user/apps/system/mojoelf.c:1157: undefined reference to `assert'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1158: undefined reference to `assert'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1159: undefined reference to `assert'
ld: mojoelf.o: in function `Malloc':
/home/tyson/Orion/user/apps/system/mojoelf.c:375: undefined reference to `calloc'
ld: mojoelf.o: in function `map_pages':
/home/tyson/Orion/user/apps/system/mojoelf.c:590: undefined reference to `mmap'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:596: undefined reference to `memset'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:606: undefined reference to `memcpy'
ld: mojoelf.o: in function `Malloc':
/home/tyson/Orion/user/apps/system/mojoelf.c:375: undefined reference to `calloc'
ld: mojoelf.o: in function `add_exported_symbol':
/home/tyson/Orion/user/apps/system/mojoelf.c:1057: undefined reference to `strlen'
ld: mojoelf.o: in function `Malloc':
/home/tyson/Orion/user/apps/system/mojoelf.c:375: undefined reference to `calloc'
ld: mojoelf.o: in function `add_exported_symbol':
/home/tyson/Orion/user/apps/system/mojoelf.c:1061: undefined reference to `strcpy'
ld: mojoelf.o: in function `build_export_list':
/home/tyson/Orion/user/apps/system/mojoelf.c:1126: undefined reference to `assert'
ld: mojoelf.o: in function `fixup_jmprel':
/home/tyson/Orion/user/apps/system/mojoelf.c:1034: undefined reference to `assert'
ld: mojoelf.o: in function `protect_pages':
/home/tyson/Orion/user/apps/system/mojoelf.c:636: undefined reference to `mprotect'
ld: mojoelf.o: in function `Malloc':
/home/tyson/Orion/user/apps/system/mojoelf.c:375: undefined reference to `calloc'
ld: mojoelf.o: in function `load_external_dependencies':
/home/tyson/Orion/user/apps/system/mojoelf.c:866: undefined reference to `assert'
ld: mojoelf.o: in function `MOJOELF_dlopen_file':
/home/tyson/Orion/user/apps/system/mojoelf.c:1272: undefined reference to `open'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1277: undefined reference to `fstat'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1279: undefined reference to `malloc'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1281: undefined reference to `read'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1285: undefined reference to `close'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1294: undefined reference to `free'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1282: undefined reference to `__error'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1282: undefined reference to `strerror'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1291: undefined reference to `close'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1291: undefined reference to `close'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1276: undefined reference to `__error'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1276: undefined reference to `strerror'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1278: undefined reference to `__error'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1278: undefined reference to `strerror'
ld: mojoelf.o: in function `MOJOELF_dlclose':
/home/tyson/Orion/user/apps/system/mojoelf.c:1263: undefined reference to `free'
make: *** [../../Mk/l4.prog.mk:54: syslaunch] Error 1
tyson@tyson-Lenovo-ideapad-120S-14IAP:~/Orion/user/apps/system$ 

from orion.

vmlemon avatar vmlemon commented on July 23, 2024

Imported FreeBSD implementations of strcmp/memcpy

from orion.

vmlemon avatar vmlemon commented on July 23, 2024

Imported FreeBSD's strerror

from orion.

vmlemon avatar vmlemon commented on July 23, 2024

If we want to try using MojoELF, we need pthreads (see #19). :(

from orion.

vmlemon avatar vmlemon commented on July 23, 2024

Looking at https://hg.icculus.org/icculus/mojoelf/file/tip/README.txt, there seems to be various definitions for disabling the use of certain functions

from orion.

vmlemon avatar vmlemon commented on July 23, 2024

For x86, the specification at http://www.sco.com/developers/devspecs/abi386-4.pdf exists (we should also implement some of the extra functionality, and types, above-and-beyond ELF loading, later), https://www.freebsd.org/cgi/man.cgi?query=elf&sektion=3&manpath=FreeBSD+7.0-RELEASE documents some APIs/defines, http://uw714doc.sco.com/en/man/html.5/types.5.html defines some types referred to in the UNIX System V ABI, UNIXWare sysconf() is at https://pubs.opengroup.org/onlinepubs/009695399/functions/sysconf.html, https://www.sco.com/developers/gabi/latest/ch4.eheader.html documents the ELF header.

For PowerPC, Wii U RPXes are documented in https://github.com/libretro/RetroArch/blob/master/wiiu/hbl.c.

from orion.

vmlemon avatar vmlemon commented on July 23, 2024

Added some of the CellOS ELF segment types, from https://www.psdevwiki.com/ps3/SELF_File_Format_and_Decryption, for future-proofing, in support of #10...

from orion.

vmlemon avatar vmlemon commented on July 23, 2024

The current state of this is, that after implementing Enryo's liballoc, as part of #20, we now get this far:

===> Linking ./syslaunch
ld -e_start -N -L../../lib -L/usr/lib/gcc/x86_64-linux-gnu/8 -nostdlib  -melf_x86_64  -Ttext=01000000 crt0-amd64.o syslaunch.o mojoelf.o    -ll4 -lio  -llinux  -lgcc -o syslaunch
ld: mojoelf.o: in function `MOJOELF_dlclose':
/home/tyson/Orion/user/apps/system/mojoelf.c:1293: undefined reference to `munmap'
ld: mojoelf.o: in function `MOJOELF_dlopen_mem':
/home/tyson/Orion/user/apps/system/mojoelf.c:1196: undefined reference to `assert'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1197: undefined reference to `assert'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1198: undefined reference to `assert'
ld: mojoelf.o: in function `map_pages':
/home/tyson/Orion/user/apps/system/mojoelf.c:629: undefined reference to `mmap'
ld: mojoelf.o: in function `add_exported_symbol':
/home/tyson/Orion/user/apps/system/mojoelf.c:1096: undefined reference to `strlen'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1100: undefined reference to `strcpy'
ld: mojoelf.o: in function `build_export_list':
/home/tyson/Orion/user/apps/system/mojoelf.c:1165: undefined reference to `assert'
ld: mojoelf.o: in function `fixup_jmprel':
/home/tyson/Orion/user/apps/system/mojoelf.c:1073: undefined reference to `assert'
ld: mojoelf.o: in function `protect_pages':
/home/tyson/Orion/user/apps/system/mojoelf.c:675: undefined reference to `mprotect'
ld: mojoelf.o: in function `load_external_dependencies':
/home/tyson/Orion/user/apps/system/mojoelf.c:905: undefined reference to `assert'
ld: mojoelf.o: in function `MOJOELF_dlopen_file':
/home/tyson/Orion/user/apps/system/mojoelf.c:1311: undefined reference to `open'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1316: undefined reference to `fstat'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1320: undefined reference to `read'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1324: undefined reference to `close'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1321: undefined reference to `__error'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1330: undefined reference to `close'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1330: undefined reference to `close'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1315: undefined reference to `__error'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1317: undefined reference to `__error'
ld: ../../lib/liblinux.a(strerror.o): in function `strerror_r':
/home/tyson/Orion/user/lib/linux/strerror.c:91: undefined reference to `sys_nerr'
ld: ../../lib/liblinux.a(strerror.o): in function `errstr':
/home/tyson/Orion/user/lib/linux/strerror.c:77: undefined reference to `__uprefix'
ld: /home/tyson/Orion/user/lib/linux/strerror.c:77: undefined reference to `strlcpy'
ld: /home/tyson/Orion/user/lib/linux/strerror.c:78: undefined reference to `strlcat'
ld: ../../lib/liblinux.a(strerror.o): in function `strerror_r':
/home/tyson/Orion/user/lib/linux/strerror.c:101: undefined reference to `sys_errlist'
ld: /home/tyson/Orion/user/lib/linux/strerror.c:101: undefined reference to `strlcpy'
ld: ../../lib/liblinux.a(strerror.o): in function `strerror':
/home/tyson/Orion/user/lib/linux/strerror.c:125: undefined reference to `__error'
ld: syslaunch: hidden symbol `__uprefix' isn't defined
ld: final link failed: bad value
make: *** [../../Mk/l4.prog.mk:54: syslaunch] Error 1

from orion.

vmlemon avatar vmlemon commented on July 23, 2024

After importing more functions:

===> Linking ./syslaunch
ld -e_start -N -L../../lib -L/usr/lib/gcc/x86_64-linux-gnu/8 -nostdlib  -melf_x86_64  -Ttext=01000000 crt0-amd64.o syslaunch.o mojoelf.o    -ll4 -lio  -llinux  -lgcc -o syslaunch
ld: mojoelf.o: in function `MOJOELF_dlclose':
/home/tyson/Orion/user/apps/system/mojoelf.c:1293: undefined reference to `munmap'
ld: mojoelf.o: in function `MOJOELF_dlopen_mem':
/home/tyson/Orion/user/apps/system/mojoelf.c:1196: undefined reference to `assert'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1197: undefined reference to `assert'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1198: undefined reference to `assert'
ld: mojoelf.o: in function `map_pages':
/home/tyson/Orion/user/apps/system/mojoelf.c:629: undefined reference to `mmap'
ld: mojoelf.o: in function `add_exported_symbol':
/home/tyson/Orion/user/apps/system/mojoelf.c:1096: undefined reference to `strlen'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1100: undefined reference to `strcpy'
ld: mojoelf.o: in function `build_export_list':
/home/tyson/Orion/user/apps/system/mojoelf.c:1165: undefined reference to `assert'
ld: mojoelf.o: in function `fixup_jmprel':
/home/tyson/Orion/user/apps/system/mojoelf.c:1073: undefined reference to `assert'
ld: mojoelf.o: in function `protect_pages':
/home/tyson/Orion/user/apps/system/mojoelf.c:675: undefined reference to `mprotect'
ld: mojoelf.o: in function `load_external_dependencies':
/home/tyson/Orion/user/apps/system/mojoelf.c:905: undefined reference to `assert'
ld: mojoelf.o: in function `MOJOELF_dlopen_file':
/home/tyson/Orion/user/apps/system/mojoelf.c:1311: undefined reference to `open'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1316: undefined reference to `fstat'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1320: undefined reference to `read'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1324: undefined reference to `close'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1321: undefined reference to `__error'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1330: undefined reference to `close'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1330: undefined reference to `close'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1315: undefined reference to `__error'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1317: undefined reference to `__error'
ld: ../../lib/liblinux.a(strerror.o): in function `strerror_r':
/home/tyson/Orion/user/lib/linux/strerror.c:91: undefined reference to `sys_nerr'
ld: ../../lib/liblinux.a(strerror.o): in function `errstr':
/home/tyson/Orion/user/lib/linux/strerror.c:77: undefined reference to `__uprefix'
ld: /home/tyson/Orion/user/lib/linux/strerror.c:78: undefined reference to `strlcat'
ld: ../../lib/liblinux.a(strerror.o): in function `strerror_r':
/home/tyson/Orion/user/lib/linux/strerror.c:101: undefined reference to `sys_errlist'
ld: ../../lib/liblinux.a(strerror.o): in function `strerror':
/home/tyson/Orion/user/lib/linux/strerror.c:125: undefined reference to `__error'
ld: syslaunch: hidden symbol `__uprefix' isn't defined
ld: final link failed: bad value
make: *** [../../Mk/l4.prog.mk:54: syslaunch] Error 1

from orion.

vmlemon avatar vmlemon commented on July 23, 2024

Status is now:

===> Linking ./syslaunch
ld -e_start -N -L../../lib -L/usr/lib/gcc/x86_64-linux-gnu/8 -nostdlib  -melf_x86_64  -Ttext=01000000 crt0-amd64.o syslaunch.o mojoelf.o    -ll4 -lio  -llinux  -lgcc -o syslaunch
ld: mojoelf.o: in function `MOJOELF_dlclose':
/home/tyson/Orion/user/apps/system/mojoelf.c:1293: undefined reference to `munmap'
ld: mojoelf.o: in function `MOJOELF_dlopen_mem':
/home/tyson/Orion/user/apps/system/mojoelf.c:1196: undefined reference to `assert'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1197: undefined reference to `assert'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1198: undefined reference to `assert'
ld: mojoelf.o: in function `map_pages':
/home/tyson/Orion/user/apps/system/mojoelf.c:629: undefined reference to `mmap'
ld: mojoelf.o: in function `build_export_list':
/home/tyson/Orion/user/apps/system/mojoelf.c:1165: undefined reference to `assert'
ld: mojoelf.o: in function `fixup_jmprel':
/home/tyson/Orion/user/apps/system/mojoelf.c:1073: undefined reference to `assert'
ld: mojoelf.o: in function `protect_pages':
/home/tyson/Orion/user/apps/system/mojoelf.c:675: undefined reference to `mprotect'
ld: mojoelf.o: in function `load_external_dependencies':
/home/tyson/Orion/user/apps/system/mojoelf.c:905: undefined reference to `assert'
ld: mojoelf.o: in function `MOJOELF_dlopen_file':
/home/tyson/Orion/user/apps/system/mojoelf.c:1311: undefined reference to `open'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1316: undefined reference to `fstat'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1320: undefined reference to `read'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1324: undefined reference to `close'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1321: undefined reference to `__error'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1330: undefined reference to `close'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1330: undefined reference to `close'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1315: undefined reference to `__error'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1317: undefined reference to `__error'
ld: ../../lib/liblinux.a(strerror.o): in function `strerror_r':
/home/tyson/Orion/user/lib/linux/strerror.c:91: undefined reference to `sys_nerr'
ld: ../../lib/liblinux.a(strerror.o): in function `errstr':
/home/tyson/Orion/user/lib/linux/strerror.c:77: undefined reference to `__uprefix'
ld: ../../lib/liblinux.a(strerror.o): in function `strerror_r':
/home/tyson/Orion/user/lib/linux/strerror.c:101: undefined reference to `sys_errlist'
ld: ../../lib/liblinux.a(strerror.o): in function `strerror':
/home/tyson/Orion/user/lib/linux/strerror.c:125: undefined reference to `__error'
ld: syslaunch: hidden symbol `__uprefix' isn't defined
ld: final link failed: bad value
make: *** [../../Mk/l4.prog.mk:54: syslaunch] Error 1
tyson@tyson-Lenovo-ideapad-120S-14IAP:~/Orion/user/apps/system$ 

from orion.

vmlemon avatar vmlemon commented on July 23, 2024

The current status is :

===> Linking ./syslaunch
ld -e_start -N -L../../lib -L/usr/lib/gcc/x86_64-linux-gnu/8 -nostdlib  -melf_x86_64  -Ttext=01000000 crt0-amd64.o syslaunch.o mojoelf.o    -ll4 -lio  -llinux  -lgcc -o syslaunch
ld: mojoelf.o: in function `MOJOELF_dlclose':
/home/tyson/Orion/user/apps/system/mojoelf.c:1293: undefined reference to `munmap'
ld: mojoelf.o: in function `MOJOELF_dlopen_mem':
/home/tyson/Orion/user/apps/system/mojoelf.c:1196: undefined reference to `assert'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1197: undefined reference to `assert'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1198: undefined reference to `assert'
ld: mojoelf.o: in function `map_pages':
/home/tyson/Orion/user/apps/system/mojoelf.c:629: undefined reference to `mmap'
ld: mojoelf.o: in function `build_export_list':
/home/tyson/Orion/user/apps/system/mojoelf.c:1165: undefined reference to `assert'
ld: mojoelf.o: in function `fixup_jmprel':
/home/tyson/Orion/user/apps/system/mojoelf.c:1073: undefined reference to `assert'
ld: mojoelf.o: in function `protect_pages':
/home/tyson/Orion/user/apps/system/mojoelf.c:675: undefined reference to `mprotect'
ld: mojoelf.o: in function `load_external_dependencies':
/home/tyson/Orion/user/apps/system/mojoelf.c:905: undefined reference to `assert'
ld: mojoelf.o: in function `MOJOELF_dlopen_file':
/home/tyson/Orion/user/apps/system/mojoelf.c:1311: undefined reference to `open'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1320: undefined reference to `read'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1324: undefined reference to `close'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1321: undefined reference to `__error'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1330: undefined reference to `close'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1330: undefined reference to `close'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1315: undefined reference to `__error'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1317: undefined reference to `__error'
ld: ../../lib/liblinux.a(fstat.o): in function `fstat':
/home/tyson/Orion/user/lib/linux/fstat.c:44: undefined reference to `files'
ld: /home/tyson/Orion/user/lib/linux/fstat.c:57: undefined reference to `__error'
ld: /home/tyson/Orion/user/lib/linux/fstat.c:58: undefined reference to `__error'
ld: /home/tyson/Orion/user/lib/linux/fstat.c:47: undefined reference to `__error'
ld: /home/tyson/Orion/user/lib/linux/fstat.c:53: undefined reference to `__error'
ld: ../../lib/liblinux.a(strerror.o): in function `strerror_r':
/home/tyson/Orion/user/lib/linux/strerror.c:91: undefined reference to `sys_nerr'
ld: ../../lib/liblinux.a(strerror.o): in function `errstr':
/home/tyson/Orion/user/lib/linux/strerror.c:77: undefined reference to `__uprefix'
ld: ../../lib/liblinux.a(strerror.o): in function `strerror_r':
/home/tyson/Orion/user/lib/linux/strerror.c:101: undefined reference to `sys_errlist'
ld: ../../lib/liblinux.a(strerror.o): in function `strerror':
/home/tyson/Orion/user/lib/linux/strerror.c:125: undefined reference to `__error'
ld: syslaunch: hidden symbol `__uprefix' isn't defined
ld: final link failed: bad value
make: *** [../../Mk/l4.prog.mk:54: syslaunch] Error 1

from orion.

vmlemon avatar vmlemon commented on July 23, 2024

Linkage status:

===> Linking ./syslaunch
ld -e_start -N -L../../lib -L/usr/lib/gcc/x86_64-linux-gnu/8 -nostdlib  -melf_x86_64  -Ttext=01000000 crt0-amd64.o syslaunch.o mojoelf.o    -ll4 -lio  -llinux  -lgcc -o syslaunch
ld: mojoelf.o: in function `MOJOELF_dlclose':
/home/tyson/Orion/user/apps/system/mojoelf.c:1293: undefined reference to `munmap'
ld: mojoelf.o: in function `MOJOELF_dlopen_mem':
/home/tyson/Orion/user/apps/system/mojoelf.c:1196: undefined reference to `assert'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1197: undefined reference to `assert'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1198: undefined reference to `assert'
ld: mojoelf.o: in function `map_pages':
/home/tyson/Orion/user/apps/system/mojoelf.c:629: undefined reference to `mmap'
ld: mojoelf.o: in function `build_export_list':
/home/tyson/Orion/user/apps/system/mojoelf.c:1165: undefined reference to `assert'
ld: mojoelf.o: in function `fixup_jmprel':
/home/tyson/Orion/user/apps/system/mojoelf.c:1073: undefined reference to `assert'
ld: mojoelf.o: in function `protect_pages':
/home/tyson/Orion/user/apps/system/mojoelf.c:675: undefined reference to `mprotect'
ld: mojoelf.o: in function `load_external_dependencies':
/home/tyson/Orion/user/apps/system/mojoelf.c:905: undefined reference to `assert'
ld: mojoelf.o: in function `MOJOELF_dlopen_file':
/home/tyson/Orion/user/apps/system/mojoelf.c:1311: undefined reference to `open'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1320: undefined reference to `read'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1324: undefined reference to `close'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1330: undefined reference to `close'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1330: undefined reference to `close'
ld: ../../lib/liblinux.a(fstat.o): in function `fstat':
/home/tyson/Orion/user/lib/linux/fstat.c:44: undefined reference to `files'
make: *** [../../Mk/l4.prog.mk:54: syslaunch] Error 1

from orion.

vmlemon avatar vmlemon commented on July 23, 2024

Current status is now :

===> Linking ./syslaunch
ld -e_start -N -L../../lib -L/usr/lib/gcc/x86_64-linux-gnu/8 -nostdlib  -melf_x86_64  -Ttext=01000000 crt0-amd64.o syslaunch.o mojoelf.o    -ll4 -lio  -llinux  -lgcc -o syslaunch
ld: mojoelf.o: in function `MOJOELF_dlopen_mem':
/home/tyson/Orion/user/apps/system/mojoelf.c:1205: undefined reference to `assert'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1206: undefined reference to `assert'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1207: undefined reference to `assert'
ld: mojoelf.o: in function `build_export_list':
/home/tyson/Orion/user/apps/system/mojoelf.c:1174: undefined reference to `assert'
ld: mojoelf.o: in function `fixup_jmprel':
/home/tyson/Orion/user/apps/system/mojoelf.c:1082: undefined reference to `assert'
ld: mojoelf.o:/home/tyson/Orion/user/apps/system/mojoelf.c:914: more undefined references to `assert' follow
ld: mojoelf.o: in function `MOJOELF_dlopen_file':
/home/tyson/Orion/user/apps/system/mojoelf.c:1320: undefined reference to `open'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1329: undefined reference to `read'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1333: undefined reference to `close'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1339: undefined reference to `close'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1339: undefined reference to `close'
ld: ../../lib/liblinux.a(fstat.o): in function `fstat':
/home/tyson/Orion/user/lib/linux/fstat.c:44: undefined reference to `files'
make: *** [../../Mk/l4.prog.mk:54: syslaunch] Error 1

We need to properly implement mprotect/mmap/munmap, later, instead of just implementing stubs.

from orion.

vmlemon avatar vmlemon commented on July 23, 2024

Now we're at :

===> Linking ./syslaunch
ld -e_start -N -L../../lib -L/usr/lib/gcc/x86_64-linux-gnu/8 -nostdlib  -melf_x86_64  -Ttext=01000000 crt0-amd64.o syslaunch.o mojoelf.o    -ll4 -lio  -llinux  -lgcc -o syslaunch
ld: mojoelf.o: in function `MOJOELF_dlopen_file':
/home/tyson/Orion/user/apps/system/mojoelf.c:1320: undefined reference to `open'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1329: undefined reference to `read'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1333: undefined reference to `close'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1339: undefined reference to `close'
ld: /home/tyson/Orion/user/apps/system/mojoelf.c:1339: undefined reference to `close'
ld: ../../lib/liblinux.a(fstat.o): in function `fstat':
/home/tyson/Orion/user/lib/linux/fstat.c:44: undefined reference to `files'
ld: ../../lib/liblinux.a(panic.o): in function `panic_action':
/home/tyson/Orion/user/lib/linux/panic.c:50: undefined reference to `getchar'
ld: /home/tyson/Orion/user/lib/linux/panic.c:52: undefined reference to `exit'
ld: ../../lib/liblinux.a(vprintf.o): in function `vprintf':
/home/tyson/Orion/user/lib/linux/vprintf.c:52: undefined reference to `__stdoutp'
ld: ../../lib/liblinux.a(vprintf.o): in function `vprintf_l':
/home/tyson/Orion/user/lib/linux/vprintf.c:57: undefined reference to `__stdoutp'
ld: ../../lib/liblinux.a(vprintf.o): in function `vprintf':
/home/tyson/Orion/user/lib/linux/vprintf.c:52: undefined reference to `vfprintf'
ld: ../../lib/liblinux.a(vprintf.o): in function `vprintf_l':
/home/tyson/Orion/user/lib/linux/vprintf.c:57: undefined reference to `vfprintf_l'
make: *** [../../Mk/l4.prog.mk:54: syslaunch] Error 1

from orion.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.