cybersecurity · intermediate · ~15 min · safe pentest lab
Extract the binding nibble.
Extract the binding from an ELF symbol's st_info byte, which packs binding in the high nibble and type in the low nibble.
Implement int symbol_binding(unsigned char info) that returns the high nibble, info >> 4.
info: one st_info byte from an ELF symbol-table entry. The grader passes fixed values.Returns int: the binding, info >> 4 (0=LOCAL, 1=GLOBAL, 2=WEAK).
symbol_binding(0x12) -> 1 (GLOBAL)
symbol_binding(0x02) -> 0 (LOCAL)
symbol_binding(0x21) -> 2 (WEAK)
An st_info byte info.
An int: the binding nibble info >> 4.
Binding is the high nibble (info >> 4).
int symbol_binding(unsigned char info) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.