> For each libcall, we need to decorate > > 1. Which library it comes from. It is OS/target dependent. > 2. The dynamic and static library names. In most cases, they > are the same. For glibc, they are different.
Is there a relatively painless way to enumerate all the possible libcalls? We could add a new plugin api and have the LTO plugin register those symbols up front. The linker would make a note of where each symbol is defined, and then automatically go back and add any objects needed to resolve any references introduced by the optimization pass. For the crtend files we could add a linker option that makes them known as endcaps, and the linker could make sure they get laid out last: ld ... -lc -lgcc ... --endcap crtend.o crtn.o That puts the special knowledge about those files back in the gcc driver. -cary