for_each_shdr_str(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… for_each_shdr_str(9) β€” like, the Kernel API Manual, bestie ✨

okay so real talk, this one lives in the Kernel API Manual and it's genuinely one of those little macros that eats and leaves no crumbs πŸ“ it's a for loop-flavoured iterator that reads strings that are in an ELF section. yes, that ELF. no cap.


✨ SYNOPSIS ✨

for_each_shdr_str (len , ehdr , sec );

that's the whole vibe check right there 🫢 (and yes, the spaces are exactly that, don't come for me, that's literally how it's written πŸ’€)


πŸŽ€ ARGUMENTS πŸŽ€

  • len β€” an "int" that's gonna hold the length of the current string. it's your little output slot, she reports back every loop πŸ’–
  • ehdr β€” a pointer to the ehdr of the ELF file. like, the ELF header itself, the main character πŸ‘‘
  • sec β€” the section that has the strings to iterate on. this is the section you're serving, the one with the good stuff in it 🌸

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so picture this: it's a for loop 😭 and it iterates over all the nul terminated strings that are in a given ELF section. every single one. not a single string left behind, periodt πŸ’…

the variable "str" will hold the current string for each iteration β€” so like, every time you go around the loop, str is your girl, she's got the string of the moment ✨

and the len you passed in? she'll contain the strlen of that string. so you get the string and its length, no extra math, we love an efficient queen 🌈


πŸ’œ SEE ALSO πŸ’œ

  • Kernel file ./scripts/tracepoint-update.c β€” go look, iykyk πŸ‘€

fr fr bestie, that's the whole page. no hidden options, no top-secret env vars, just a loop that hands you strings and their lengths like a good friend who brings you a snack πŸ“

mwah πŸ’‹ β€” this one came from ./scripts, dated October 2026, and i'm obsessed with her honestly πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from