> > So I have following plan to solve this issue - write a utility
> > that takes .o file and splits it to several smaller .o files based
> > on sections (according to COFF specification this should not be so
> > hard), then forms a library out of them that will be feed to ld.
> It is my understanding that you cannot break object files into smaller
> The compiler creates object files with the assumption that you or the
> will not do that. For example, consider the case when foo() and bar()
> reside in the same object and foo() calls bar(). The compiler may
> machine code at that location that says "branch 112 bytes past the current
> location of the program counter". This assumes that the relative position
> bar() is fixed with respect to foo(). If you were to attempt to break the
> object file into parts and reorder or omit some parts then this assumption
> no longer be true and the code may be broken.
Above is true, but AFAIK only as long as both funtions reside in same
section. Anyway, it is possible to compile with -ffunction-sections switch
and then each function has its own section, that is independent from others.
All I want to do is to split COFF by these sections.
There are of course problems - most notable is problem with global
constructors and destructors sections. I will have to find a way how to
include these sections (by adding some sort of reference to it) if any of
splitted object is included in resulted .exe. So far I do not know whether
this is possible....
Other than that, splitting COFF does not seem to be extremly hard
operation, from what I have learnt so far. But it is always possible that I
have overlooked something - that is why I try to gather more info before
following dead end :)