long x_square(struct point *p) { return p->x * p->x; } // main.c #include <geo-v1.h> int main(void) { struct point p = ... point p = { ... }; long x2 = x_square(&p); return arr[x2]; }
long x_square(struct point *p) { return p->x * p->x; } // main.c #include <geo-v1.h> int main(void) { struct point p = ... point p = { ... }; long x2 = x_square(&p); return arr[x2]; }
long x_square(struct point *p) { return p->x * p->x; } // main.c #include <geo-v1.h> int main(void) { struct point p = ... point p = { ... }; long x2 = x_square(&p); return arr[x2]; }
}; // geo.c #include <geo-v1.h> long x_square(struct point *p) { return p->x * p->x; } // main.c #include <geo-v1.h> int main(void) { struct point p = ... point p = { ... }; long x2 = x_square(&p); return arr[x2]; }
return p->x * p->x; } // main.c #include <geo.h> int main(void) { struct point p = ... point p = { ... }; long x2 = x_square(&p); return arr[x2]; } // geo.h struct point { long x; long y; };
return p->x * p->x; } // main.c #include <geo.h> int main(void) { struct point p = { .x = 2, .y = 1, }; /* you get x2 == 4 */ long x2 = x_square(&p); /* use x2 to index arr*/ return arr[x2]; } // geo.h struct point { long x; long y; };
-I$(pwd) -shared -o ./libgeo.so geo.c # Run the application, WITHOUT re-compiling # It’s not ran at all (no “Calculating”) $ ./main; echo $? ./main: symbol lookup error: ./main: undefined symbol: x_square
point $ gcc -I$(pwd) -shared -o ./libgeo.so geo.c # Run the application, WITHOUT re-compiling # No crash, just wrong $ ./main; echo $? Calculating 1 # returns 1 instead of 4
point $ gcc -I$(pwd) -shared -o ./libgeo.so geo.c # Run the application, without re-compiling # No crash, everything works $ ./main; echo $? Calculating 4 # returns 4 as expected
library # Let's use the ubiquitous libc here libc = ctypes.CDLL('libc.so.6') # This is the _exact_ same printf you # get in C libc.printf(b'Hello %s!\n', b'world')
Chaiken Binary Banshees and Digital Demons by JeanHeyd Meneide C Isn't A Programming Language Anymore by Aria Desires To Save C, We Must Save ABI by JeanHeyd Meneide Pair Your Compilers At The ABI Café by Aria Desires The Lost Art of Structure Packing by Eric S. Raymond Application binary interface compatibility testing with libabigail by Frank Eigler ABI stable symbols - Linux Kernel Documentation A look at dynamic linking - LWN.net by Daroc Alden