Linker : Make a map of typeinfo to vtable

Frederick Virchanza Gotham cauldwell.thomas@gmail.com
Thu Jan 25 23:02:32 GMT 2024


On Thu, Jan 25, 2024 at 10:17 AM Frederick Virchanza Gotham wrote:
>
> So, somehow, I need to call 'bfd_final_link' in
> order get the offsets for the vtables inside their section, but then I
> need to append my own array onto the end of the section, and then
> perform the final link.


I've had another idea.

Inside the function "bfd_generic_link_add_one_symbol", I can keep a
record of all vtables and typeinfo's encountered. So before the call
to 'ldwrite', I know how many entries there will be in my array. So
before I call 'ldwrite', I add a new symbol to the readonly section
for my array, calling it "__map_typeinfo_vtable", and I give it the
correct size. I fill my array with all zeroes, except for a 128-Bit
magic number at the beginning: 021fed6674b3ac813273c5909cb7d0ac. So
then after I call 'ldwrite' and have produced the final binary file, I
re-open the binary file and I scan through it until I find my magic
number (i.e. 3c1fed6f74bb6c814173c5409cb7d0aa), and I replace it with
the correct data.

This will work I think. I'm gonna try code it now.


More information about the Binutils mailing list