Open ysbaddaden opened 6 years ago
About 2. [addresses of DATA and BSS sections]:
mach-o/getsect.h
.
There appears to be a dyld solution, too, compatible with macOS and iOS.__data_start
, __bss_start
and __end
.etext
, edata
and end
, see edata(3)Documentation on this topic is scarce... sigh.
The DATA and BSS sections detection has been added in c86fba829222c4c0571a0cf0106dd2e76963437f but hasn't been tested because we need others to be implemented too.
@ysbaddaden Can support for musl
be added?
So that a project can be static compiled with the gc
Yes, this is the one thing to implement (from the issue description):
detect the stack bottom: in linux we can read the 28th value from
/proc/self/stat
as perproc(5)
.
We only support the linux-gnu target, which is the computer I use everyday. There are a few places that require platform specific stuff that may need to be adapted:
The physical memory getter, see
GC_getMemoryLimit
in include/memory.h; GC uses this for the default maximum allocatable memory limit;Pointers to the DATA and BSS sections, which are special fixed-size stacks where (un)initialized constants are allocated; see
GC_Collector_init
in src/collector.c where I use symbols injected by the linker__data_start
,__bss_start
and_end
; I assume those symbols exist for most ELF executables, but maybe not. Mach-O and PE probably use something entirely different.The stack bottom detector, only used to detect the beginning of the main thread stack, to properly initialize the stack for the main fiber; see
GC.stack_bottom
in src/immix.cr;__libc_stack_end
);/proc/self/stat
as per proc(5) (warning: don't useFile
because it's a class and relies onGC.malloc
).Note: the issue is about supporting other POSIX systems, supporting Windows will require to use a
File Mapping
withINVALID_HANDLE_VALUE
instead of an anonymousmmap
.