Code for this traversal from a core file would be probably best to
write as
a new program based on elfutils.
The libdwfl logic that --core gets you actually does this already.
(This is how e.g. -e exe --core core can work when the core lacks build IDs.)
It just doesn't punt the other modules discovered by "raw" ELF image
detection, so those will remain in the list too but ordered last (I think)
and with their names taken from embedded DT_SONAME in the core (not usually
there unless it's an ELF-headers dump) or default "[dso]" instead of the
"proper" name from link_map.
If you wanted to change this to give more control to the caller of libdwfl,
that should not be hard.
Thanks,
Roland