You can use libdw from elfutils to do the add2line work straightforwardly in library code. But this is nothing to do with libc, so this is not the place to discuss it further.