#Custom linker args

1 messages · Page 1 of 1 (latest)

latent anvil
#

Can I specify custom linker args in build.zig? I’m using lld

sly oasis
#

you can specify a linker script, per compile artifact, that can do every think you can do with args and more.

latent anvil
#

I need to specify the options --no-rosegment and maybe -zseparate-code as well to try to circunvent an android backtrace bug

#

but I'm not sure how todo it via a linker script

sly oasis
#

I am not very familiar so these are guesses made with a little bit of searching:
--no-rosegment: in the linker script you would simply not specify an output rodata section, i think you'd direct that data to text, but data might also make sense.
-zseparate-code aligns the first section in a PT_LOAD segments such that executable and non executable segments dont overlap. you specify what segments are PT_LOAD and what are executable or not, not sure how you set the alignments to not overlap. This feels like a detail zig can figure out from the target, so you might not need to do anything.
hopefully someone more knowledgable comes along

latent anvil
#

At least I manage to re-link my .so by manually invoke ld adding the options I needed, and it indeed solved the backtrace issue so at least I'm in the right track at least, thanks for your help

sly oasis
#

for some reason i thought a linker script was a better idea, but that is certainly easier. Probably cause I dont know what you are doing.

#

regardless I have a bunch of linker articles i will read tomorrow! yay!

latent anvil
#

I tring to build a android game, haha. The android ecosystem is a mess, every phone is a different pile of bugs and I need crash reports, thankfuly android has an automatic system built for me that send these crash reports to me via a google play ANR so I can debug it.

Issue is the crash report is also buggy, haha, so to get meaningful stracktraces I need to go though a lot of hoops, heres a more detailed story https://discord.com/channels/605571803288698900/1429809292747476992