I have a number of things that I would like to see added to
collect2. If there is interest in them, I'll volunteer to do the
work. I am not sure of the process of making suggestions like this
so if there is another format, please let me know.
Changes to collect2:
1) Added the ability for collect2 to stop after the creation of
the .c file which also implies an option to give the .c file a name.
Maybe:
--c-file-only=foo.c
2) Same as #1 but with the object file. Maybe:
--o-file-only=foo.o
3) Right now collect2 looks at suffixes. It would be nice to do one
or both of the following two things:
3a) An option to add suffixes used for object files. Maybe:
--object-suffix=.32o
to add the .32o suffix.
3b) Look at the magic number in the files to determine if they are an
object file that needs to be looked at. This could be an option.
The pitfall is that on AIX, an archive can have 32 bit object files
and 64 bit object files and the linker pulls out the ones it needs.
The way this is done usually is to have foo.c compile to foo.32o and
foo.64o and then put all the object files into one archive. gcc
instead has path/libxxx.a and path/ppc64/libxxx.a If the only
difference is the 32/64 bitness, those could be combined. This is
what old farts like me are use to.
This system confuses collect2 in two places. If I do g++ foo.32o -o
foo, collect2 never looks at foo.32o for constructors and destructors
(or frame tables). The trick I did was to put my object files into
an archive and then collect2 scans them. I am building a driver
which means I need it in 32 bit form as well as 64 bit form. I
assume if I had both my 32 bit object files and my 64 bit object
files in the same archive, collect2 would scan all of them which is
not the right thing to have happen. collect2 could look at the magic
numbers and resolve both of these short comings. (collect2 knows if
it is in 32 bit mode or in 64 bit mode.)
4) collect2 on AIX has two arguments that it passes to ld that can
not be removed. I'm wondering if those should be added in only if -
nostdlib is not specified (or some other way to accomplish the same
task). There may be other flags to ld like this as well but I don't
think so. Right now, to get around this problem I have a script
called ld in my path before the real ld and the script strips out the
two arguments that I don't want.
Thank you,
Perry Smith
btw Thank you to David, Ian, Gabby, and others. I now have a tiny
driver that loads. It has a constructor and destructor for a global
object (which gets called). It throws an exception (on purpose) and
the exception is caught. The malloc and frees match up. Everything
looks good. I can finally move on to actually writing a device
driver...!!! Yippie!!!