Changeset 2eadda9 in mainline
- Timestamp:
- 2018-07-11T17:45:30Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 99d3123
- Parents:
- c2c4127
- git-author:
- Jiří Zárevúcky <jiri.zarevucky@…> (2018-07-11 17:08:12)
- git-committer:
- Jiří Zárevúcky <jiri.zarevucky@…> (2018-07-11 17:45:30)
- Location:
- uspace
- Files:
-
- 1 added
- 30 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/Makefile.common
rc2c4127 r2eadda9 118 118 LIBDLTEST_PREFIX = $(LIB_PREFIX)/dltest 119 119 120 START_FILES = $(LIBC_PREFIX)/ arch/$(UARCH)/src/entry.o120 START_FILES = $(LIBC_PREFIX)/crt0.o $(LIBC_PREFIX)/crt1.o 121 121 122 122 AFLAGS = --fatal-warnings … … 137 137 endif 138 138 139 ifeq ($(STATIC_BUILD),y) 140 BASE_LIBS = $(LIBC_PREFIX)/libc.a 141 else 142 BASE_LIBS = $(LIBC_PREFIX)/libc.so.0 139 ifneq ($(STATIC_BUILD),y) 143 140 LINK_DYNAMIC = y 141 endif 142 143 BASE_LIBS = 144 145 ifneq ($(LIBRARY),libc) 146 ifeq ($(STATIC_BUILD),y) 147 BASE_LIBS += $(LIBC_PREFIX)/libc.a 148 else 149 BASE_LIBS += $(LIBC_PREFIX)/libc.so.0 150 endif 144 151 endif 145 152 … … 286 293 287 294 LIB_CFLAGS = $(CFLAGS) -fPIC 288 LIB_LDFLAGS = $(LDFLAGS) -shared -Wl,-soname,$(LSONAME) 295 LIB_LDFLAGS = $(LDFLAGS) -shared -Wl,-soname,$(LSONAME) -Wl,--no-undefined,--no-allow-shlib-undefined 289 296 290 297 AS_CFLAGS := $(addprefix -Xassembler ,$(AFLAGS)) … … 340 347 341 348 ifneq ($(filter %.cpp %.cc %.cxx, $(SOURCES)),) 342 $(BINARY): $(LINKER_SCRIPT) $(OBJECTS) $(LIBTAGS) $(CXX_BASE_LIBS)349 $(BINARY): $(LINKER_SCRIPT) $(OBJECTS) $(LIBTAGS) 343 350 $(CXX) $(CXXFLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS) -T $(LINKER_SCRIPT) -Wl,-Map,$@.map -o $@ $(START_FILES) $(OBJECTS) $(LIBARGS) $(CXX_BASE_LIBS) 344 351 else 345 $(BINARY): $(LINKER_SCRIPT) $(OBJECTS) $(LIBTAGS) $(BASE_LIBS)352 $(BINARY): $(LINKER_SCRIPT) $(OBJECTS) $(LIBTAGS) 346 353 $(CC) $(CFLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS) -T $(LINKER_SCRIPT) -Wl,-Map,$@.map -o $@ $(START_FILES) $(OBJECTS) $(LIBARGS) $(BASE_LIBS) 347 354 endif … … 350 357 351 358 ifneq ($(TEST_BINARY),) 352 $(TEST_BINARY): $(LINKER_SCRIPT) $(TEST_OBJECTS) $(TEST_BINARY_LIBS) $(LIBTAGS) $(BASE_LIBS)359 $(TEST_BINARY): $(LINKER_SCRIPT) $(TEST_OBJECTS) $(TEST_BINARY_LIBS) $(LIBTAGS) 353 360 $(CC) $(CFLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS) -T $(LINKER_SCRIPT) -Wl,-Map,$@.map -o $@ $(START_FILES) $(TEST_OBJECTS) $(TEST_BINARY_LIBS) $(LIBARGS) $(BASE_LIBS) 354 361 endif … … 368 375 369 376 $(SLIBRARY): $(LIB_LINKER_SCRIPT) $(LIBRARY).la 370 $(CC) $(CFLAGS) $(LIB_LDFLAGS) $(EXTRA_LDFLAGS) -T $(LIB_LINKER_SCRIPT) -Wl,-Map,$@.map -o $@ -Wl,--whole-archive $(LIBRARY).la -Wl,--no-whole-archive 377 $(CC) $(CFLAGS) $(LIB_LDFLAGS) $(EXTRA_LDFLAGS) -T $(LIB_LINKER_SCRIPT) -Wl,-Map,$@.map -o $@ -Wl,--whole-archive $(LIBRARY).la -Wl,--no-whole-archive $(LIBARGS) $(BASE_LIBS) 371 378 372 379 $(LSONAME): -
uspace/lib/c/Makefile
rc2c4127 r2eadda9 207 207 include $(USPACE_PREFIX)/Makefile.common 208 208 209 $(LIBC_PREFIX)/crt0.o: $(LIBC_PREFIX)/arch/$(UARCH)/src/entry.o 210 cp $< $@ 211 212 $(LIBC_PREFIX)/crt1.o: $(LIBC_PREFIX)/generic/crt/entry.o 213 cp $< $@ 214 209 215 $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld: $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld.in 210 216 $(CC) $(DEFS) $(CFLAGS) -DLIBC_PATH=$(CURDIR) -E -x c $< | grep -v "^\#" > $@ -
uspace/lib/c/arch/abs32le/_link.ld.in
rc2c4127 r2eadda9 57 57 58 58 .init_array : { 59 #ifndef SHLIB 59 60 PROVIDE_HIDDEN (__init_array_start = .); 61 #endif 60 62 KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) 61 63 KEEP (*(.init_array .ctors)) 64 #ifndef SHLIB 62 65 PROVIDE_HIDDEN (__init_array_end = .); 66 #endif 63 67 } 64 68 65 69 .fini_array : { 70 #ifndef SHLIB 66 71 PROVIDE_HIDDEN (__fini_array_start = .); 72 #endif 67 73 KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*))) 68 74 KEEP (*(.fini_array .dtors)) 75 #ifndef SHLIB 69 76 PROVIDE_HIDDEN (__fini_array_end = .); 77 #endif 70 78 } 71 79 -
uspace/lib/c/arch/abs32le/src/entry.c
rc2c4127 r2eadda9 30 30 */ 31 31 32 #include "../../../generic/private/libc.h"33 32 #include <stddef.h> 34 33 35 34 extern void _start(void); 35 extern void __c_start(void *); 36 36 37 37 /* Normally, the entry point is defined in assembly for the architecture. */ … … 39 39 void _start(void) 40 40 { 41 __ libc_main(NULL);41 __c_start(NULL); 42 42 } 43 43 -
uspace/lib/c/arch/amd64/_link.ld.in
rc2c4127 r2eadda9 57 57 58 58 .init_array : { 59 #ifndef SHLIB 59 60 PROVIDE_HIDDEN (__init_array_start = .); 61 #endif 60 62 KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) 61 63 KEEP (*(.init_array .ctors)) 64 #ifndef SHLIB 62 65 PROVIDE_HIDDEN (__init_array_end = .); 66 #endif 63 67 } 64 68 65 69 .fini_array : { 70 #ifndef SHLIB 66 71 PROVIDE_HIDDEN (__fini_array_start = .); 72 #endif 67 73 KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*))) 68 74 KEEP (*(.fini_array .dtors)) 75 #ifndef SHLIB 69 76 PROVIDE_HIDDEN (__fini_array_end = .); 77 #endif 70 78 } 71 79 -
uspace/lib/c/arch/amd64/src/entry.S
rc2c4127 r2eadda9 29 29 #include <abi/asmtool.h> 30 30 31 . section .init, "ax"31 .text 32 32 33 33 .org 0 … … 46 46 47 47 # %rdi was deliberately chosen as the first argument is also in %rdi 48 # Pass PCB pointer to __ libc_main(no operation)49 call __ libc_main48 # Pass PCB pointer to __c_start (no operation) 49 call __c_start -
uspace/lib/c/arch/arm32/_link.ld.in
rc2c4127 r2eadda9 55 55 56 56 .init_array : { 57 #ifndef SHLIB 57 58 PROVIDE_HIDDEN (__init_array_start = .); 59 #endif 58 60 KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) 59 61 KEEP (*(.init_array .ctors)) 62 #ifndef SHLIB 60 63 PROVIDE_HIDDEN (__init_array_end = .); 64 #endif 61 65 } 62 66 63 67 .fini_array : { 68 #ifndef SHLIB 64 69 PROVIDE_HIDDEN (__fini_array_start = .); 70 #endif 65 71 KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*))) 66 72 KEEP (*(.fini_array .dtors)) 73 #ifndef SHLIB 67 74 PROVIDE_HIDDEN (__fini_array_end = .); 75 #endif 68 76 } 69 77 -
uspace/lib/c/arch/arm32/src/entry.S
rc2c4127 r2eadda9 29 29 #include <abi/asmtool.h> 30 30 31 . section .init, "ax"31 .text 32 32 33 33 .org 0 … … 51 51 sub fp, ip, #4 52 52 53 # Pass pcb_ptr to __ libc_mainas the first argument (in r0)53 # Pass pcb_ptr to __c_start as the first argument (in r0) 54 54 mov r0, r1 55 bl __ libc_main55 bl __c_start 56 56 57 57 .data -
uspace/lib/c/arch/ia32/_link.ld.in
rc2c4127 r2eadda9 116 116 117 117 .init_array : { 118 PROVIDE (__init_array_start = .); 118 #ifndef SHLIB 119 PROVIDE_HIDDEN (__init_array_start = .); 120 #endif 119 121 KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) 120 122 KEEP (*(.init_array .ctors)) 121 PROVIDE (__init_array_end = .); 123 #ifndef SHLIB 124 PROVIDE_HIDDEN (__init_array_end = .); 125 #endif 122 126 } 123 127 124 128 .fini_array : { 125 PROVIDE (__fini_array_start = .); 129 #ifndef SHLIB 130 PROVIDE_HIDDEN (__fini_array_start = .); 131 #endif 126 132 KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*))) 127 133 KEEP (*(.fini_array .dtors)) 128 PROVIDE (__fini_array_end = .); 134 #ifndef SHLIB 135 PROVIDE_HIDDEN (__fini_array_end = .); 136 #endif 129 137 } 130 138 -
uspace/lib/c/arch/ia32/src/entry.S
rc2c4127 r2eadda9 32 32 INTEL_SEP = 11 33 33 34 . section .init, "ax"34 .text 35 35 36 36 .org 0 … … 65 65 movl %esp, %ebp 66 66 67 # Pass the PCB pointer to __ libc_mainas the first argument67 # Pass the PCB pointer to __c_start as the first argument 68 68 pushl %edi 69 call __ libc_main69 call __c_start -
uspace/lib/c/arch/ia64/_link.ld.in
rc2c4127 r2eadda9 65 65 66 66 .init_array : { 67 #ifndef SHLIB 67 68 PROVIDE_HIDDEN (__init_array_start = .); 69 #endif 68 70 KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) 69 71 KEEP (*(.init_array .ctors)) 72 #ifndef SHLIB 70 73 PROVIDE_HIDDEN (__init_array_end = .); 74 #endif 71 75 } 72 76 73 77 .fini_array : { 78 #ifndef SHLIB 74 79 PROVIDE_HIDDEN (__fini_array_start = .); 80 #endif 75 81 KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*))) 76 82 KEEP (*(.fini_array .dtors)) 83 #ifndef SHLIB 77 84 PROVIDE_HIDDEN (__fini_array_end = .); 85 #endif 78 86 } 79 87 -
uspace/lib/c/arch/ia64/src/entry.S
rc2c4127 r2eadda9 29 29 #include <abi/asmtool.h> 30 30 31 . section .init, "ax"31 .text 32 32 33 33 .org 0 … … 42 42 movl gp = __gp 43 43 44 # Pass PCB pointer as the first argument to __ libc_main44 # Pass PCB pointer as the first argument to __c_start 45 45 mov out0 = r2 ;; 46 br.call.sptk.many b0 = __ libc_main46 br.call.sptk.many b0 = __c_start 47 47 -
uspace/lib/c/arch/mips32/_link.ld.in
rc2c4127 r2eadda9 62 62 63 63 .init_array : { 64 #ifndef SHLIB 64 65 PROVIDE_HIDDEN (__init_array_start = .); 66 #endif 65 67 KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) 66 68 KEEP (*(.init_array .ctors)) 69 #ifndef SHLIB 67 70 PROVIDE_HIDDEN (__init_array_end = .); 71 #endif 68 72 } 69 73 70 74 .fini_array : { 75 #ifndef SHLIB 71 76 PROVIDE_HIDDEN (__fini_array_start = .); 77 #endif 72 78 KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*))) 73 79 KEEP (*(.fini_array .dtors)) 80 #ifndef SHLIB 74 81 PROVIDE_HIDDEN (__fini_array_end = .); 82 #endif 75 83 } 76 84 -
uspace/lib/c/arch/mips32/src/entry.S
rc2c4127 r2eadda9 31 31 32 32 .text 33 .section .init, "ax"34 33 35 34 .set noreorder … … 51 50 .cprestore 16 52 51 53 # Pass pcb_ptr to __ libc_main() as the first argument. It is already52 # Pass pcb_ptr to __c_start() as the first argument. It is already 54 53 # in $a0. As the first argument is passed in $a0, no operation 55 54 # is needed. 56 55 57 jal __ libc_main56 jal __c_start 58 57 nop 59 58 -
uspace/lib/c/arch/ppc32/_link.ld.in
rc2c4127 r2eadda9 55 55 56 56 .init_array : { 57 #ifndef SHLIB 57 58 PROVIDE_HIDDEN (__init_array_start = .); 59 #endif 58 60 KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) 59 61 KEEP (*(.init_array .ctors)) 62 #ifndef SHLIB 60 63 PROVIDE_HIDDEN (__init_array_end = .); 64 #endif 61 65 } 62 66 63 67 .fini_array : { 68 #ifndef SHLIB 64 69 PROVIDE_HIDDEN (__fini_array_start = .); 70 #endif 65 71 KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*))) 66 72 KEEP (*(.fini_array .dtors)) 73 #ifndef SHLIB 67 74 PROVIDE_HIDDEN (__fini_array_end = .); 75 #endif 68 76 } 69 77 -
uspace/lib/c/arch/ppc32/src/entry.S
rc2c4127 r2eadda9 29 29 #include <abi/asmtool.h> 30 30 31 . section .init, "ax"31 .text 32 32 33 33 .org 0 … … 45 45 stwu %r1, -16(%r1) 46 46 47 # Pass the PCB pointer to __ libc_main() as the first argument.47 # Pass the PCB pointer to __c_start() as the first argument. 48 48 # The first argument is passed in r3. 49 49 mr %r3, %r6 50 bl __ libc_main50 bl __c_start -
uspace/lib/c/arch/riscv64/_link.ld.in
rc2c4127 r2eadda9 54 54 55 55 .init_array : { 56 #ifndef SHLIB 56 57 PROVIDE_HIDDEN (__init_array_start = .); 58 #endif 57 59 KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) 58 60 KEEP (*(.init_array .ctors)) 61 #ifndef SHLIB 59 62 PROVIDE_HIDDEN (__init_array_end = .); 63 #endif 60 64 } 61 65 62 66 .fini_array : { 67 #ifndef SHLIB 63 68 PROVIDE_HIDDEN (__fini_array_start = .); 69 #endif 64 70 KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*))) 65 71 KEEP (*(.fini_array .dtors)) 72 #ifndef SHLIB 66 73 PROVIDE_HIDDEN (__fini_array_end = .); 74 #endif 67 75 } 68 76 -
uspace/lib/c/arch/riscv64/src/entry.c
rc2c4127 r2eadda9 30 30 */ 31 31 32 #include "../../../generic/private/libc.h"33 34 32 extern void _start(void); 33 extern void __c_start(void *); 35 34 36 35 // FIXME: Implement properly. … … 38 37 void _start(void) 39 38 { 40 __ libc_main((void *)0);39 __c_start(0); 41 40 } 42 41 -
uspace/lib/c/arch/sparc64/_link.ld.in
rc2c4127 r2eadda9 58 58 59 59 .init_array : { 60 #ifndef SHLIB 60 61 PROVIDE_HIDDEN (__init_array_start = .); 62 #endif 61 63 KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) 62 64 KEEP (*(.init_array .ctors)) 65 #ifndef SHLIB 63 66 PROVIDE_HIDDEN (__init_array_end = .); 67 #endif 64 68 } 65 69 66 70 .fini_array : { 71 #ifndef SHLIB 67 72 PROVIDE_HIDDEN (__fini_array_start = .); 73 #endif 68 74 KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*))) 69 75 KEEP (*(.fini_array .dtors)) 76 #ifndef SHLIB 70 77 PROVIDE_HIDDEN (__fini_array_end = .); 78 #endif 71 79 } 72 80 -
uspace/lib/c/arch/sparc64/src/entry.S
rc2c4127 r2eadda9 29 29 #include <abi/asmtool.h> 30 30 31 . section .init, "ax"31 .text 32 32 33 33 .org 0 … … 46 46 add %g0, -0x7ff, %fp 47 47 48 # Pass pcb_ptr as the first argument to __ libc_main()49 call __ libc_main48 # Pass pcb_ptr as the first argument to __c_start() 49 call __c_start 50 50 mov %i1, %o0 -
uspace/lib/c/generic/as.c
rc2c4127 r2eadda9 60 60 { 61 61 return (void *) __SYSCALL5(SYS_AS_AREA_CREATE, (sysarg_t) base, 62 (sysarg_t) size, (sysarg_t) flags, (sysarg_t) _ end,62 (sysarg_t) size, (sysarg_t) flags, (sysarg_t) __progsymbols.end, 63 63 (sysarg_t) pager_info); 64 64 } -
uspace/lib/c/generic/async/server.c
rc2c4127 r2eadda9 1397 1397 // FIXME: The source has no business deciding destination address. 1398 1398 return ipc_answer_3(call->cap_handle, EOK, (sysarg_t) src, (sysarg_t) flags, 1399 (sysarg_t) _ end);1399 (sysarg_t) __progsymbols.end); 1400 1400 } 1401 1401 … … 1449 1449 assert(call); 1450 1450 1451 return ipc_answer_2(call->cap_handle, EOK, (sysarg_t) _ end,1451 return ipc_answer_2(call->cap_handle, EOK, (sysarg_t) __progsymbols.end, 1452 1452 (sysarg_t) dst); 1453 1453 } -
uspace/lib/c/generic/ddi.c
rc2c4127 r2eadda9 72 72 { 73 73 return (errno_t) __SYSCALL5(SYS_PHYSMEM_MAP, (sysarg_t) phys, 74 pages, flags, (sysarg_t) virt, (sysarg_t) _ end);74 pages, flags, (sysarg_t) virt, (sysarg_t) __progsymbols.end); 75 75 } 76 76 … … 145 145 return (errno_t) __SYSCALL6(SYS_DMAMEM_MAP, (sysarg_t) size, 146 146 (sysarg_t) map_flags, (sysarg_t) flags | DMAMEM_FLAGS_ANONYMOUS, 147 (sysarg_t) phys, (sysarg_t) virt, (sysarg_t) _ end);147 (sysarg_t) phys, (sysarg_t) virt, (sysarg_t) __progsymbols.end); 148 148 } 149 149 -
uspace/lib/c/generic/elf/elf_mod.c
rc2c4127 r2eadda9 356 356 (void *)((uint8_t *)entry->p_vaddr + elf->bias); 357 357 358 if (entry->p_filesz == 0) { 359 DPRINTF("Zero-sized ELF interp string.\n"); 360 return EE_INVALID; 361 } 358 362 if (elf->info->interp[entry->p_filesz - 1] != '\0') { 359 363 DPRINTF("Unterminated ELF interp string.\n"); -
uspace/lib/c/generic/libc.c
rc2c4127 r2eadda9 61 61 #endif 62 62 63 progsymbols_t __progsymbols; 64 63 65 static bool env_setup = false; 64 66 … … 116 118 * C++ Static constructor calls. 117 119 */ 118 ptrdiff_t init_array_entries = (__init_array_end - __init_array_start);119 120 120 for (int i = init_array_entries - 1; i >= 0; --i) 121 __init_array_start[i](); 121 if (__progsymbols.preinit_array) { 122 for (int i = __progsymbols.preinit_array_len - 1; i >= 0; --i) 123 __progsymbols.preinit_array[i](); 124 } 125 126 if (__progsymbols.init_array) { 127 for (int i = __progsymbols.init_array_len - 1; i >= 0; --i) 128 __progsymbols.init_array[i](); 129 } 122 130 123 131 /* … … 125 133 * according the result 126 134 */ 127 int retval = main(argc, argv);135 int retval = __progsymbols.main(argc, argv); 128 136 exit(retval); 129 137 } … … 136 144 * when the respective constructor is called. 137 145 */ 138 ptrdiff_t fini_array_entries = (__fini_array_end - __fini_array_start);139 146 140 for (int i = 0; i < fini_array_entries; ++i)141 __ fini_array_start[i]();147 for (int i = 0; i < __progsymbols.fini_array_len; ++i) 148 __progsymbols.fini_array[i](); 142 149 143 150 if (env_setup) { … … 148 155 149 156 __SYSCALL1(SYS_TASK_EXIT, false); 150 151 /* Unreachable */ 152 while (true) 153 ; 157 __builtin_unreachable(); 154 158 } 155 159 … … 157 161 { 158 162 __SYSCALL1(SYS_TASK_EXIT, true); 159 160 /* Unreachable */ 161 while (true) 162 ; 163 __builtin_unreachable(); 163 164 } 164 165 -
uspace/lib/c/generic/private/libc.h
rc2c4127 r2eadda9 36 36 #define LIBC_PRIVATE_LIBC_H_ 37 37 38 #include <types/common.h> 39 40 /* Type of the main C function. */ 41 typedef int (*main_fn_t)(int, char **); 42 38 43 /** 39 44 * Used for C++ constructors/destructors … … 43 48 typedef void (*fini_array_entry_t)(); 44 49 45 extern init_array_entry_t __init_array_start[]; 46 extern init_array_entry_t __init_array_end[]; 47 extern fini_array_entry_t __fini_array_start[]; 48 extern fini_array_entry_t __fini_array_end[]; 50 typedef struct { 51 main_fn_t main; 52 const void *elfstart; 53 const void *end; 54 init_array_entry_t *preinit_array; 55 int preinit_array_len; 56 init_array_entry_t *init_array; 57 int init_array_len; 58 fini_array_entry_t *fini_array; 59 int fini_array_len; 60 } progsymbols_t; 49 61 50 extern unsigned char _end[];62 extern progsymbols_t __progsymbols; 51 63 extern void __libc_main(void *) __attribute__((noreturn)); 52 64 extern void __libc_exit(int) __attribute__((noreturn)); 53 65 extern void __libc_abort(void) __attribute__((noreturn)); 54 extern int main(int, char *[]);55 66 56 67 #endif -
uspace/lib/c/generic/rtld/module.c
rc2c4127 r2eadda9 51 51 #include <rtld/module.h> 52 52 53 #include "../private/libc.h" 54 53 55 /** Create module for static executable. 54 56 * … … 73 75 74 76 const elf_segment_header_t *tls = 75 elf_get_phdr(__ executable_start, PT_TLS);77 elf_get_phdr(__progsymbols.elfstart, PT_TLS); 76 78 77 79 if (tls) { 78 uintptr_t bias = elf_get_bias(__ executable_start);80 uintptr_t bias = elf_get_bias(__progsymbols.elfstart); 79 81 module->tdata = (void *) (tls->p_vaddr + bias); 80 82 module->tdata_size = tls->p_filesz; -
uspace/lib/c/generic/tls.c
rc2c4127 r2eadda9 45 45 #include <elf/elf.h> 46 46 47 #include "private/libc.h" 48 47 49 #ifdef CONFIG_RTLD 48 50 #include <rtld/rtld.h> … … 61 63 62 64 const elf_segment_header_t *tls = 63 elf_get_phdr(__ executable_start, PT_TLS);65 elf_get_phdr(__progsymbols.elfstart, PT_TLS); 64 66 65 67 if (tls == NULL) … … 88 90 89 91 const elf_segment_header_t *tls = 90 elf_get_phdr(__ executable_start, PT_TLS);92 elf_get_phdr(__progsymbols.elfstart, PT_TLS); 91 93 if (tls == NULL) 92 94 return NULL; 93 95 94 uintptr_t bias = elf_get_bias(__ executable_start);96 uintptr_t bias = elf_get_bias(__progsymbols.elfstart); 95 97 size_t align = max(tls->p_align, _Alignof(tcb_t)); 96 98 … … 128 130 #endif 129 131 const elf_segment_header_t *tls = 130 elf_get_phdr(__ executable_start, PT_TLS);132 elf_get_phdr(__progsymbols.elfstart, PT_TLS); 131 133 132 134 assert(tls != NULL); -
uspace/lib/c/include/elf/elf.h
rc2c4127 r2eadda9 41 41 #include <libarch/elf.h> 42 42 43 extern const uint8_t __executable_start[];44 45 43 extern const elf_segment_header_t *elf_get_phdr(const void *, unsigned); 46 44 extern uintptr_t elf_get_bias(const void *); -
uspace/lib/posix/Makefile
rc2c4127 r2eadda9 37 37 SPECS = gcc.specs 38 38 LIBC_LINKER_SCRIPT = $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld 39 LIBC_STARTUP_FILE = $(START_FILES)40 39 EXPORT_LINKER_SCRIPT = link.ld 41 EXPORT_STARTUP_FILE = crt0.o42 40 43 41 EXPORT_FILES = \ … … 47 45 $(LIBSOFTINT_PREFIX)/libsoftint.a \ 48 46 $(LIBC_PREFIX)/libc.a \ 47 $(LIBC_PREFIX)/crt0.o \ 48 $(LIBC_PREFIX)/crt1.o \ 49 49 $(LIBRARY).a \ 50 $(EXPORT_STARTUP_FILE) \51 50 $(EXPORT_LINKER_SCRIPT) \ 52 51 $(SPECS) … … 95 94 -L$$(HELENOS_EXPORT_ROOT)/lib \ 96 95 -T link.ld \ 97 $(EXPORT_STARTUP_FILE) 96 $$(HELENOS_EXPORT_ROOT)/lib/crt0.o \ 97 $$(HELENOS_EXPORT_ROOT)/lib/crt1.o 98 98 99 99 EXPORT_LDLIBS = \
Note:
See TracChangeset
for help on using the changeset viewer.