Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ELF Loader Implementation #18

Open
vmlemon opened this issue Sep 10, 2019 · 15 comments
Open

ELF Loader Implementation #18

vmlemon opened this issue Sep 10, 2019 · 15 comments
Labels
enhancement New feature or request

Comments

@vmlemon
Copy link
Owner

vmlemon commented Sep 10, 2019

In order to implement #7, and the JUEL vision, we need to have a robust implementation of ELF, as well as support for things like execv(), and fork(), in either Sigma0, a userland library, KickStart, or the root task, where everything can easily access it.

It would also be useful to support dynamic linking, ABI branding, switchable syscall tables, and advanced functionality exposed by the ELF specification, and executables.

Conveniently, inside /user/contrib/elf-loader, we have some kind of ELF implementation, which when I tried to compile under PPC64, resulted in:

common  include  Makefile  Makefile.in  platform
[root@fedora28 elf-loader]# make
===> Rebuilding ./Makefile
config.status: creating ./Makefile
config.status: creating config.h
config.status: config.h is unchanged
/bin/bash: clangobjdump: command not found
===> Making dependencies in .
clang-6.0: warning: -lssp: 'linker' input unused [-Wunused-command-line-argument]
clang-6.0: warning: argument unused during compilation: '-mno-red-zone' [-Wunused-command-line-argument]
make[1]: Entering directory '/root/Orion/user/serv/sigma0'
===> Rebuilding ./Makefile
config.status: creating ./Makefile
config.status: creating config.h
config.status: config.h is unchanged
===> Making dependencies in .
clang-6.0: warning: -lssp: 'linker' input unused [-Wunused-command-line-argument]
clang-6.0: warning: argument unused during compilation: '-mno-red-zone' [-Wunused-command-line-argument]
===> Rebuilding ./Makefile
config.status: creating ./Makefile
config.status: creating config.h
config.status: config.h is unchanged
make[2]: Entering directory '/root/Orion/user/lib/l4'
===> Rebuilding ./Makefile
config.status: creating ./Makefile
config.status: creating config.h
config.status: config.h is unchanged
===> debug.cc
clang -x c++ -I../../include -I../.. -I/usr/bin/../lib/gcc/x86_64-linux-gnu/8/include   -fno-stack-protector -nostdinc -g -O2 -m64 -mno-red-zone   -fno-stack-protector -lssp -O2 -g -Wall -Wshadow   -fno-stack-protector  -Wno-conversion -fno-exceptions -c debug.cc -o debug.o
clang-6.0: warning: -lssp: 'linker' input unused [-Wunused-command-line-argument]
clang-6.0: warning: argument unused during compilation: '-mno-red-zone' [-Wunused-command-line-argument]
In file included from debug.cc:31:
In file included from ../../include/l4/kip.h:35:
../../include/l4/types.h:379:27: warning: use of GNU old-style field designator
      extension [-Wgnu-designator]
    return (L4_Clock_t) { raw : l.raw + r };
                          ^~~~~
                          .raw = 
../../include/l4/types.h:384:27: warning: use of GNU old-style field designator
      extension [-Wgnu-designator]
    return (L4_Clock_t) { raw : l.raw + r };
                          ^~~~~
                          .raw = 
../../include/l4/types.h:389:27: warning: use of GNU old-style field designator
      extension [-Wgnu-designator]
    return (L4_Clock_t) { raw : l.raw + r.raw };
                          ^~~~~
                          .raw = 
../../include/l4/types.h:394:27: warning: use of GNU old-style field designator
      extension [-Wgnu-designator]
    return (L4_Clock_t) { raw : l.raw - r };
                          ^~~~~
                          .raw = 
../../include/l4/types.h:399:27: warning: use of GNU old-style field designator
      extension [-Wgnu-designator]
    return (L4_Clock_t) { raw : l.raw - r };
                          ^~~~~
                          .raw = 
../../include/l4/types.h:404:27: warning: use of GNU old-style field designator
      extension [-Wgnu-designator]
    return (L4_Clock_t) { raw : l.raw - r.raw };
                          ^~~~~
                          .raw = 
../../include/l4/types.h:410:27: warning: use of GNU old-style field designator
      extension [-Wgnu-designator]
    return (L4_Clock_t) { raw : c.raw + r };
                          ^~~~~
                          .raw = 
../../include/l4/types.h:415:27: warning: use of GNU old-style field designator
      extension [-Wgnu-designator]
    return (L4_Clock_t) { raw : c.raw - r };
                          ^~~~~
                          .raw = 
../../include/l4/types.h:521:13: warning: use of GNU old-style field designator
      extension [-Wgnu-designator]
            return L4_Never;
                   ^
../../include/l4/types.h:493:33: note: expanded from macro 'L4_Never'
#define L4_Never        ((L4_Time_t) { raw : 0UL })
                                       ^
../../include/l4/types.h:532:13: warning: use of GNU old-style field designator
      extension [-Wgnu-designator]
            return L4_Never;
                   ^
../../include/l4/types.h:493:33: note: expanded from macro 'L4_Never'
#define L4_Never        ((L4_Time_t) { raw : 0UL })
                                       ^
In file included from debug.cc:31:
In file included from ../../include/l4/kip.h:36:
In file included from ../../include/l4/powerpc64/syscalls.h:36:
In file included from ../../include/l4/message.h:37:
../../include/l4/powerpc64/vregs.h:41:12: warning: variable 'utcb' is
      uninitialized when used here [-Wuninitialized]
    return utcb;
           ^~~~
../../include/l4/powerpc64/vregs.h:39:29: note: initialize the variable 'utcb'
      to silence this warning
    register L4_Word_t *utcb asm("r13");
                            ^
                             = nullptr
In file included from debug.cc:31:
In file included from ../../include/l4/kip.h:36:
In file included from ../../include/l4/powerpc64/syscalls.h:36:
../../include/l4/message.h:727:15: error: use of undeclared identifier
      '__L4_Lsb'; did you mean '__L4_Msb'?
    for (reg+=__L4_Lsb(mask); mask!=0; mask>>=__L4_Lsb(mask)+1,reg+=__L4...
              ^~~~~~~~
              __L4_Msb
../../include/l4/powerpc64/specials.h:37:15: note: '__L4_Msb' declared here
L4_INLINE int __L4_Msb( L4_Word_t w )
              ^
In file included from debug.cc:31:
In file included from ../../include/l4/kip.h:36:
In file included from ../../include/l4/powerpc64/syscalls.h:36:
../../include/l4/message.h:727:47: error: use of undeclared identifier
      '__L4_Lsb'; did you mean '__L4_Msb'?
    for (reg+=__L4_Lsb(mask); mask!=0; mask>>=__L4_Lsb(mask)+1,reg+=__L4...
                                              ^~~~~~~~
                                              __L4_Msb
../../include/l4/powerpc64/specials.h:37:15: note: '__L4_Msb' declared here
L4_INLINE int __L4_Msb( L4_Word_t w )
              ^
In file included from debug.cc:31:
In file included from ../../include/l4/kip.h:36:
In file included from ../../include/l4/powerpc64/syscalls.h:36:
../../include/l4/message.h:727:69: error: use of undeclared identifier
      '__L4_Lsb'; did you mean '__L4_Msb'?
    for (reg+=__L4_Lsb(mask); mask!=0; mask>>=__L4_Lsb(mask)+1,reg+=__L4_Lsb(mas...
                                                                    ^~~~~~~~
                                                                    __L4_Msb
../../include/l4/powerpc64/specials.h:37:15: note: '__L4_Msb' declared here
L4_INLINE int __L4_Msb( L4_Word_t w )
              ^
In file included from debug.cc:31:
In file included from ../../include/l4/kip.h:36:
In file included from ../../include/l4/powerpc64/syscalls.h:36:
../../include/l4/message.h:746:20: error: use of undeclared identifier
      '__L4_Lsb'; did you mean '__L4_Msb'?
    for (fault_id+=__L4_Lsb(fault_id_mask_low); fault_id_mask_low != 0;  
                   ^~~~~~~~
                   __L4_Msb
../../include/l4/powerpc64/specials.h:37:15: note: '__L4_Msb' declared here
L4_INLINE int __L4_Msb( L4_Word_t w )
              ^
In file included from debug.cc:31:
In file included from ../../include/l4/kip.h:36:
In file included from ../../include/l4/powerpc64/syscalls.h:36:
../../include/l4/message.h:747:23: error: use of undeclared identifier
      '__L4_Lsb'; did you mean '__L4_Msb'?
         fault_id_mask_low>>=__L4_Lsb(fault_id_mask_low)+1,fault_id+=__L...
                             ^~~~~~~~
                             __L4_Msb
../../include/l4/powerpc64/specials.h:37:15: note: '__L4_Msb' declared here
L4_INLINE int __L4_Msb( L4_Word_t w )
              ^
In file included from debug.cc:31:
In file included from ../../include/l4/kip.h:36:
In file included from ../../include/l4/powerpc64/syscalls.h:36:
../../include/l4/message.h:747:63: error: use of undeclared identifier
      '__L4_Lsb'; did you mean '__L4_Msb'?
  ...fault_id_mask_low>>=__L4_Lsb(fault_id_mask_low)+1,fault_id+=__L4_Lsb(fau...
                                                                 ^~~~~~~~
                                                                 __L4_Msb
../../include/l4/powerpc64/specials.h:37:15: note: '__L4_Msb' declared here
L4_INLINE int __L4_Msb( L4_Word_t w )
              ^
In file included from debug.cc:31:
In file included from ../../include/l4/kip.h:36:
In file included from ../../include/l4/powerpc64/syscalls.h:36:
../../include/l4/message.h:755:20: error: use of undeclared identifier
      '__L4_Lsb'; did you mean '__L4_Msb'?
    for (fault_id+=__L4_Lsb(fault_id_mask_high); fault_id_mask_high != 0;  
                   ^~~~~~~~
                   __L4_Msb
../../include/l4/powerpc64/specials.h:37:15: note: '__L4_Msb' declared here
L4_INLINE int __L4_Msb( L4_Word_t w )
              ^
In file included from debug.cc:31:
In file included from ../../include/l4/kip.h:36:
In file included from ../../include/l4/powerpc64/syscalls.h:36:
../../include/l4/message.h:756:24: error: use of undeclared identifier
      '__L4_Lsb'; did you mean '__L4_Msb'?
         fault_id_mask_high>>=__L4_Lsb(fault_id_mask_high)+1,fault_id+=_...
                              ^~~~~~~~
                              __L4_Msb
../../include/l4/powerpc64/specials.h:37:15: note: '__L4_Msb' declared here
L4_INLINE int __L4_Msb( L4_Word_t w )
              ^
In file included from debug.cc:31:
In file included from ../../include/l4/kip.h:36:
In file included from ../../include/l4/powerpc64/syscalls.h:36:
../../include/l4/message.h:756:65: error: use of undeclared identifier
      '__L4_Lsb'; did you mean '__L4_Msb'?
  ...fault_id_mask_high>>=__L4_Lsb(fault_id_mask_high)+1,fault_id+=__L4_Lsb(f...
                                                                   ^~~~~~~~
                                                                   __L4_Msb
../../include/l4/powerpc64/specials.h:37:15: note: '__L4_Msb' declared here
L4_INLINE int __L4_Msb( L4_Word_t w )
              ^
In file included from debug.cc:31:
In file included from ../../include/l4/kip.h:36:
In file included from ../../include/l4/powerpc64/syscalls.h:36:
../../include/l4/message.h:808:15: error: use of undeclared identifier
      '__L4_Lsb'; did you mean '__L4_Msb'?
    for (reg+=__L4_Lsb(mask); mask!=0; mask>>=__L4_Lsb(mask)+1,reg+=__L4...
              ^~~~~~~~
              __L4_Msb
../../include/l4/powerpc64/specials.h:37:15: note: '__L4_Msb' declared here
L4_INLINE int __L4_Msb( L4_Word_t w )
              ^
In file included from debug.cc:31:
In file included from ../../include/l4/kip.h:36:
In file included from ../../include/l4/powerpc64/syscalls.h:36:
../../include/l4/message.h:808:47: error: use of undeclared identifier
      '__L4_Lsb'; did you mean '__L4_Msb'?
    for (reg+=__L4_Lsb(mask); mask!=0; mask>>=__L4_Lsb(mask)+1,reg+=__L4...
                                              ^~~~~~~~
                                              __L4_Msb
../../include/l4/powerpc64/specials.h:37:15: note: '__L4_Msb' declared here
L4_INLINE int __L4_Msb( L4_Word_t w )
              ^
In file included from debug.cc:31:
In file included from ../../include/l4/kip.h:36:
In file included from ../../include/l4/powerpc64/syscalls.h:36:
../../include/l4/message.h:808:69: error: use of undeclared identifier
      '__L4_Lsb'; did you mean '__L4_Msb'?
    for (reg+=__L4_Lsb(mask); mask!=0; mask>>=__L4_Lsb(mask)+1,reg+=__L4_Lsb(mas...
                                                                    ^~~~~~~~
                                                                    __L4_Msb
../../include/l4/powerpc64/specials.h:37:15: note: '__L4_Msb' declared here
L4_INLINE int __L4_Msb( L4_Word_t w )
              ^
In file included from debug.cc:31:
In file included from ../../include/l4/kip.h:36:
In file included from ../../include/l4/powerpc64/syscalls.h:36:
../../include/l4/message.h:862:15: error: use of undeclared identifier
      '__L4_Lsb'; did you mean '__L4_Msb'?
    for (reg+=__L4_Lsb(mask); mask!=0; mask>>=__L4_Lsb(mask)+1,reg+=__L4...
              ^~~~~~~~
              __L4_Msb
../../include/l4/powerpc64/specials.h:37:15: note: '__L4_Msb' declared here
L4_INLINE int __L4_Msb( L4_Word_t w )
              ^
In file included from debug.cc:31:
In file included from ../../include/l4/kip.h:36:
In file included from ../../include/l4/powerpc64/syscalls.h:36:
../../include/l4/message.h:862:47: error: use of undeclared identifier
      '__L4_Lsb'; did you mean '__L4_Msb'?
    for (reg+=__L4_Lsb(mask); mask!=0; mask>>=__L4_Lsb(mask)+1,reg+=__L4...
                                              ^~~~~~~~
                                              __L4_Msb
../../include/l4/powerpc64/specials.h:37:15: note: '__L4_Msb' declared here
L4_INLINE int __L4_Msb( L4_Word_t w )
              ^
In file included from debug.cc:31:
In file included from ../../include/l4/kip.h:36:
In file included from ../../include/l4/powerpc64/syscalls.h:36:
../../include/l4/message.h:862:69: error: use of undeclared identifier
      '__L4_Lsb'; did you mean '__L4_Msb'?
    for (reg+=__L4_Lsb(mask); mask!=0; mask>>=__L4_Lsb(mask)+1,reg+=__L4_Lsb(mas...
                                                                    ^~~~~~~~
                                                                    __L4_Msb
../../include/l4/powerpc64/specials.h:37:15: note: '__L4_Msb' declared here
L4_INLINE int __L4_Msb( L4_Word_t w )
              ^
In file included from debug.cc:31:
In file included from ../../include/l4/kip.h:36:
../../include/l4/powerpc64/syscalls.h:125:29: warning: use of GNU old-style
      field designator extension [-Wgnu-designator]
    return (L4_ThreadId_t) {raw: r3};
                            ^~~~
                            .raw = 
../../include/l4/powerpc64/syscalls.h:320:27: warning: use of GNU old-style
      field designator extension [-Wgnu-designator]
    return (L4_MsgTag_t){ raw: mr0 };   /* mr0 */
                          ^~~~
                          .raw = 
In file included from debug.cc:32:
In file included from ../../include/l4/tracebuffer.h:37:
../../include/l4/thread.h:260:49: warning: use of GNU old-style field designator
      extension [-Wgnu-designator]
        return L4_ExchangeRegisters (t, 0, 0, 0, 0, 0, L4_nilthread,
                                                       ^
../../include/l4/types.h:299:46: note: expanded from macro 'L4_nilthread'
#define L4_nilthread      ((L4_ThreadId_t) { raw : 0UL})
                                             ^
In file included from debug.cc:32:
In file included from ../../include/l4/tracebuffer.h:37:
../../include/l4/thread.h:285:49: warning: use of GNU old-style field designator
      extension [-Wgnu-designator]
        return L4_ExchangeRegisters (t, 0, 0, 0, 0, 0, L4_nilthread,
                                                       ^
../../include/l4/types.h:299:46: note: expanded from macro 'L4_nilthread'
#define L4_nilthread      ((L4_ThreadId_t) { raw : 0UL})
                                             ^
In file included from debug.cc:32:
In file included from ../../include/l4/tracebuffer.h:37:
../../include/l4/thread.h:304:59: warning: use of GNU old-style field designator
      extension [-Wgnu-designator]
    (void) L4_ExchangeRegisters (t, (1 << 9), 0, 0, 0, 0, L4_nilthread,
                                                          ^
../../include/l4/types.h:299:46: note: expanded from macro 'L4_nilthread'
#define L4_nilthread      ((L4_ThreadId_t) { raw : 0UL})
                                             ^
In file included from debug.cc:32:
In file included from ../../include/l4/tracebuffer.h:37:
../../include/l4/thread.h:316:64: warning: use of GNU old-style field designator
      extension [-Wgnu-designator]
    (void) L4_ExchangeRegisters (t, (1 << 6), 0, 0, 0, handle, L4_nilthread,
                                                               ^
../../include/l4/types.h:299:46: note: expanded from macro 'L4_nilthread'
#define L4_nilthread      ((L4_ThreadId_t) { raw : 0UL})
                                             ^
In file included from debug.cc:32:
In file included from ../../include/l4/tracebuffer.h:37:
../../include/l4/thread.h:338:59: warning: use of GNU old-style field designator
      extension [-Wgnu-designator]
    (void) L4_ExchangeRegisters (t, (1 << 9), 0, 0, 0, 0, L4_nilthread,
                                                          ^
../../include/l4/types.h:299:46: note: expanded from macro 'L4_nilthread'
#define L4_nilthread      ((L4_ThreadId_t) { raw : 0UL})
                                             ^
In file included from debug.cc:32:
In file included from ../../include/l4/tracebuffer.h:37:
../../include/l4/thread.h:372:63: warning: use of GNU old-style field designator
      extension [-Wgnu-designator]
    (void) L4_ExchangeRegisters (t, (1 << 8) + 6, 0, 0, 0, 0, L4_nilthread,
                                                              ^
../../include/l4/types.h:299:46: note: expanded from macro 'L4_nilthread'
#define L4_nilthread      ((L4_ThreadId_t) { raw : 0UL})
                                             ^
In file included from debug.cc:32:
In file included from ../../include/l4/tracebuffer.h:37:
../../include/l4/thread.h:383:6: warning: use of GNU old-style field designator
      extension [-Wgnu-designator]
                                 L4_nilthread,
                                 ^
../../include/l4/types.h:299:46: note: expanded from macro 'L4_nilthread'
#define L4_nilthread      ((L4_ThreadId_t) { raw : 0UL})
                                             ^
In file included from debug.cc:32:
In file included from ../../include/l4/tracebuffer.h:37:
../../include/l4/thread.h:396:6: warning: use of GNU old-style field designator
      extension [-Wgnu-designator]
                                 L4_nilthread,
                                 ^
../../include/l4/types.h:299:46: note: expanded from macro 'L4_nilthread'
#define L4_nilthread      ((L4_ThreadId_t) { raw : 0UL})
                                             ^
In file included from debug.cc:32:
In file included from ../../include/l4/tracebuffer.h:37:
../../include/l4/thread.h:422:6: warning: use of GNU old-style field designator
      extension [-Wgnu-designator]
                                 L4_nilthread, &state.raw, &dummy, &dummy,
                                 ^
../../include/l4/types.h:299:46: note: expanded from macro 'L4_nilthread'
#define L4_nilthread      ((L4_ThreadId_t) { raw : 0UL})
                                             ^
In file included from debug.cc:32:
In file included from ../../include/l4/tracebuffer.h:37:
../../include/l4/thread.h:438:6: warning: use of GNU old-style field designator
      extension [-Wgnu-designator]
                                 L4_nilthread, &state.raw, sp, ip, flags,
                                 ^
../../include/l4/types.h:299:46: note: expanded from macro 'L4_nilthread'
#define L4_nilthread      ((L4_ThreadId_t) { raw : 0UL})
                                             ^
In file included from debug.cc:32:
In file included from ../../include/l4/tracebuffer.h:37:
../../include/l4/thread.h:459:6: warning: use of GNU old-style field designator
      extension [-Wgnu-designator]
                                 L4_nilthread, &state.raw, &dummy, &dummy,
                                 ^
../../include/l4/types.h:299:46: note: expanded from macro 'L4_nilthread'
#define L4_nilthread      ((L4_ThreadId_t) { raw : 0UL})
                                             ^
In file included from debug.cc:32:
In file included from ../../include/l4/tracebuffer.h:37:
../../include/l4/thread.h:476:6: warning: use of GNU old-style field designator
      extension [-Wgnu-designator]
                                 L4_nilthread, &state.raw, sp, ip, flags,
                                 ^
../../include/l4/types.h:299:46: note: expanded from macro 'L4_nilthread'
#define L4_nilthread      ((L4_ThreadId_t) { raw : 0UL})
                                             ^
In file included from debug.cc:32:
In file included from ../../include/l4/tracebuffer.h:37:
../../include/l4/thread.h:499:6: warning: use of GNU old-style field designator
      extension [-Wgnu-designator]
                                 L4_nilthread, &state.raw, &dummy, &dummy,
                                 ^
../../include/l4/types.h:299:46: note: expanded from macro 'L4_nilthread'
#define L4_nilthread      ((L4_ThreadId_t) { raw : 0UL})
                                             ^
In file included from debug.cc:32:
In file included from ../../include/l4/tracebuffer.h:37:
../../include/l4/thread.h:517:6: warning: use of GNU old-style field designator
      extension [-Wgnu-designator]
                                 L4_nilthread, &state.raw, sp, ip, flags,
                                 ^
../../include/l4/types.h:299:46: note: expanded from macro 'L4_nilthread'
#define L4_nilthread      ((L4_ThreadId_t) { raw : 0UL})
                                             ^
In file included from debug.cc:32:
In file included from ../../include/l4/tracebuffer.h:37:
../../include/l4/thread.h:540:6: warning: use of GNU old-style field designator
      extension [-Wgnu-designator]
                                 L4_nilthread, &state.raw, &dummy, &dummy,
                                 ^
../../include/l4/types.h:299:46: note: expanded from macro 'L4_nilthread'
#define L4_nilthread      ((L4_ThreadId_t) { raw : 0UL})
                                             ^
In file included from debug.cc:32:
In file included from ../../include/l4/tracebuffer.h:37:
../../include/l4/thread.h:556:6: warning: use of GNU old-style field designator
      extension [-Wgnu-designator]
                                 L4_nilthread, &state.raw, sp, ip, flags,
                                 ^
../../include/l4/types.h:299:46: note: expanded from macro 'L4_nilthread'
#define L4_nilthread      ((L4_ThreadId_t) { raw : 0UL})
                                             ^
In file included from debug.cc:32:
In file included from ../../include/l4/tracebuffer.h:37:
../../include/l4/thread.h:582:9: warning: use of GNU old-style field designator
      extension [-Wgnu-designator]
                             L4_nilthread, HandlerThread, (void *) -1);
                             ^
../../include/l4/types.h:299:46: note: expanded from macro 'L4_nilthread'
#define L4_nilthread      ((L4_ThreadId_t) { raw : 0UL})
                                             ^
In file included from debug.cc:32:
In file included from ../../include/l4/tracebuffer.h:37:
../../include/l4/thread.h:588:9: warning: use of GNU old-style field designator
      extension [-Wgnu-designator]
                             L4_nilthread, InterruptThread, (void *) -1);
                             ^
../../include/l4/types.h:299:46: note: expanded from macro 'L4_nilthread'
#define L4_nilthread      ((L4_ThreadId_t) { raw : 0UL})
                                             ^
In file included from debug.cc:32:
In file included from ../../include/l4/tracebuffer.h:37:
../../include/l4/thread.h:595:76: warning: use of GNU old-style field designator
      extension [-Wgnu-designator]
  ...(dest, L4_EXREGS_CTRLXFER_CONF_FLAG, 0, 0 , 0, 0, L4_nilthread,
                                                       ^
../../include/l4/types.h:299:46: note: expanded from macro 'L4_nilthread'
#define L4_nilthread      ((L4_ThreadId_t) { raw : 0UL})
                                             ^
In file included from debug.cc:32:
In file included from ../../include/l4/tracebuffer.h:37:
../../include/l4/thread.h:604:76: warning: use of GNU old-style field designator
      extension [-Wgnu-designator]
  ...(dest, L4_EXREGS_CTRLXFER_READ_FLAG, 0, 0 , 0, 0, L4_nilthread,
                                                       ^
../../include/l4/types.h:299:46: note: expanded from macro 'L4_nilthread'
#define L4_nilthread      ((L4_ThreadId_t) { raw : 0UL})
                                             ^
In file included from debug.cc:32:
In file included from ../../include/l4/tracebuffer.h:37:
../../include/l4/thread.h:613:77: warning: use of GNU old-style field designator
      extension [-Wgnu-designator]
  ...(dest, L4_EXREGS_CTRLXFER_WRITE_FLAG, 0, 0 , 0, 0, L4_nilthread,
                                                        ^
../../include/l4/types.h:299:46: note: expanded from macro 'L4_nilthread'
#define L4_nilthread      ((L4_ThreadId_t) { raw : 0UL})
                                             ^
34 warnings and 15 errors generated.
make[2]: *** [../../Mk/l4.build.mk:58: debug.o] Error 1
make[2]: Leaving directory '/root/Orion/user/lib/l4'
make[1]: *** [../../Mk/l4.prog.mk:57: ../../lib/l4/libl4.a] Error 2
make[1]: Leaving directory '/root/Orion/user/serv/sigma0'
make: *** [../../Mk/l4.prog.mk:57: ../../serv/sigma0/sigma0] Error 2
[root@fedora28 elf-loader]# 

I'd need to see what functionality it provides, the APIs exposed, and if it can be extended, without breaking it for the pre-boot environment, before we can try to exploit it.

@vmlemon vmlemon added the enhancement New feature or request label Sep 10, 2019
@vmlemon
Copy link
Owner Author

vmlemon commented Sep 14, 2019

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

@vmlemon
Copy link
Owner Author

vmlemon commented Sep 14, 2019

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$ 

@vmlemon
Copy link
Owner Author

vmlemon commented Sep 14, 2019

Imported FreeBSD implementations of strcmp/memcpy

@vmlemon
Copy link
Owner Author

vmlemon commented Sep 14, 2019

Imported FreeBSD's strerror

@vmlemon
Copy link
Owner Author

vmlemon commented Sep 15, 2019

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

@vmlemon
Copy link
Owner Author

vmlemon commented Oct 1, 2019

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

@vmlemon
Copy link
Owner Author

vmlemon commented Oct 4, 2019

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.

@vmlemon
Copy link
Owner Author

vmlemon commented Oct 4, 2019

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...

@vmlemon
Copy link
Owner Author

vmlemon commented Oct 6, 2019

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

@vmlemon
Copy link
Owner Author

vmlemon commented Oct 6, 2019

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

@vmlemon
Copy link
Owner Author

vmlemon commented Oct 6, 2019

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$ 

@vmlemon
Copy link
Owner Author

vmlemon commented Oct 6, 2019

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

@vmlemon
Copy link
Owner Author

vmlemon commented Oct 6, 2019

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

@vmlemon
Copy link
Owner Author

vmlemon commented Oct 6, 2019

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.

@vmlemon
Copy link
Owner Author

vmlemon commented Oct 6, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant