#Undefined symbols __zig_probe_stack and others

1 messages · Page 1 of 1 (latest)

solar stirrup
#

I'm making a kernel in zig but I'm getting those linker errors. Is there anything I can add to the build script to disable stack checking ? I'm currently building a static library.

I'm also getting undefined references for memset and memcpy despite setting the target to freestanding and link_libc to false

Can anyone please help me ? Thanks in advance !

#

I got it to stop by adding setRuntimeSafety to false in my function but I'd like to find a way to just have it happen without me needing to add it to every function

cobalt dagger
#

You can either bundle compiler_rt in the static lib

lib.bundle_compiler_rt = true;
lib.pie = true;

or set the .optimize = ReleaseSmall, for b.addStaticLibrary to disable safety checks

solar stirrup
cobalt dagger
#

it's runtime for safety checks and emulations for things that hardware don't support natively

solar stirrup
cobalt dagger
#

it will call panic

solar stirrup
cobalt dagger
#

yeah

solar stirrup
#

Alright thank you very much, I'll test all that once I get home

cobalt dagger
solar stirrup
#

My stack is currently set up a bit weird

#

I just have a big block of memory I set sp to before jumping into the kernel entry point which is a naked c function which then calls the main zig function with the sysv abi

#

I'm not sure how it'll try to build a stack trace from that

solar stirrup
#

I see

cobalt dagger
#

yeah

solar stirrup
#

Neat ! Thank you

cobalt dagger
solar stirrup
cobalt dagger
#

the zig std itself won't do anything for you (except giving useful utility functions), but that's showcasing approach to have stacktraces on baremetal in custom panic

#

also, the panic function is deprecated, it's going to be replaced by Panic namespace after 0.14

solar stirrup
cobalt dagger
#

Not sure, might not be in 0.13 indeed

#

can always pub const panic = Panic.call; in your main.zig to prepare for it though

lime hemlock
solar stirrup
#

Thank you again !

solar stirrup
#

Is that normal ?

cobalt dagger
#

you are compiling with Debug or Safe mode right?

solar stirrup
cobalt dagger
#

can you show the code you tried to trigger panic with

solar stirrup
#

that's never 0

cobalt dagger
#

what is framebuffer_phys?

solar stirrup
#

physical address of the framebuffer, but I'm just using it because it's an external symbol that's never 0

cobalt dagger
#

I tried triggering undefined behavior by writing into an array outside of its bounds but it just gave me a page fault instead of panicking
I don't see any write here though

solar stirrup
cobalt dagger
#

Did you remove the @setRuntimeSafety(false) from your code?

solar stirrup
#

the old code was

var a = [_]i32{ 1, 2, 3 };
a[kinput.kinput.framebuffer_phys] = 123;
solar stirrup
#

oh wait

#

uh

#

maybe not in that specific function

#

:P

#

well now I feel stupid

#

thanks x)

cobalt dagger