Merge pull request #142 from Geertiebear/mlibc-gcc

mlibc-gcc wrapper and various fixes
This commit is contained in:
Alexander van der Grinten 2020-08-23 18:24:54 +02:00 committed by GitHub
commit 1db7107729
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 79 additions and 6 deletions

View file

@ -85,7 +85,3 @@ packages:
environ:
DESTDIR: '@THIS_COLLECT_DIR@'
quiet: true
- args: ['cp', '/usr/lib/x86_64-linux-gnu/crti.o', '@THIS_COLLECT_DIR@/usr/lib']
quiet: true
- args: ['cp', '/usr/lib/x86_64-linux-gnu/crtn.o', '@THIS_COLLECT_DIR@/usr/lib']
quiet: true

View file

@ -283,7 +283,7 @@ void ObjectRepository::_fetchFromPhdrs(SharedObject *object, void *phdr_pointer,
tls_offset = phdr->p_vaddr;
case PT_INTERP:
object->interpreterPath = frg::string<MemoryAllocator>{
(char*)(phdr->p_vaddr),
(char*)(object->baseAddress + phdr->p_vaddr),
getAllocator()
};
} break;

View file

@ -45,4 +45,30 @@ if not headers_only
install: true,
install_dir: get_option('libdir')
)
custom_target('crti',
build_by_default: true,
command: c_compiler.cmd_array() + ['-c', '-o', '@OUTPUT@', '@INPUT@'],
input: 'x86_64-crt/crti.S',
output: 'crti.o',
install: true,
install_dir: get_option('libdir')
)
custom_target('crtn',
build_by_default: true,
command: c_compiler.cmd_array() + ['-c', '-o', '@OUTPUT@', '@INPUT@'],
input: 'x86_64-crt/crtn.S',
output: 'crtn.o',
install: true,
install_dir: get_option('libdir')
)
install_data('mlibc-gcc.specs',
install_dir: get_option('libdir')
)
install_data('mlibc-gcc',
install_dir: get_option('bindir')
)
endif

2
sysdeps/linux/mlibc-gcc Executable file
View file

@ -0,0 +1,2 @@
#!/bin/sh
exec "${REALGCC:-gcc}" "$@" -specs "/usr/lib/mlibc/lib/mlibc-gcc.specs"

View file

@ -0,0 +1,32 @@
%rename cpp_options old_cpp_options
*cpp_options:
-nostdinc -isystem /usr/lib/mlibc/include -isystem include%s %(old_cpp_options)
*cc1:
%(cc1_cpu) -nostdinc -isystem /usr/lib/mlibc/include -isystem include%s
*link_libgcc:
-L/usr/lib/mlibc/lib -L .%s
*libgcc:
libgcc.a%s %:if-exists(libgcc_eh.a%s)
*startfile:
%{!shared: /usr/lib/mlibc/lib/Scrt1.o} /usr/lib/mlibc/lib/crti.o crtbeginS.o%s
*endfile:
crtendS.o%s /usr/lib/mlibc/lib/crtn.o
*link:
-dynamic-linker /usr/lib/mlibc/lib/ld.so -rpath /usr/lib/mlibc/lib -nostdlib %{shared:-shared} %{static:-static} %{rdynamic:-export-dynamic}
*esp_link:
*esp_options:
*esp_cpp_options:

View file

@ -1,5 +1,6 @@
.section .text
.global _start
_start:
lea main(%rip), %rdi
mov %rsp, %rdi
lea main(%rip), %rsi
call __mlibc_entry

View file

@ -0,0 +1,9 @@
.section .init
.global _init
_init:
push %rax
.section .fini
.global _fini
_fini:
push %rax

View file

@ -0,0 +1,7 @@
.section .init
pop %rax
ret
.section .fini
pop %rax
ret