I'm mildly interested in finding some elegant way to instantiate a statically-defined data buffer exactly big enough to serve the needs of the most demanding of several clients, when the quantity and storage needs of those clients aren't known until link time.
I'm developing a library (in the "libStaticLink.a" sense) with aspirations of being a reuseable foundation for several derivative applications. The library will have a module that defines the buffer and provides the consumer function for its data. Other library modules may provide "producing" functions with known, modest buffer size requirements. But the derivative applications may (and probably will) contain further producer functions interested in stuffing larger quantities of data into the buffer. I don't want to predeclare some "surely-big-enough" buffer size in the library module, since some applications might not produce big messages and would rather have the memory for purposes, though.
The microcontroller linkers I got to use in the 1980s would handle this sort of thing with the mechanisms they had for figuring out how large one's stack segment needed to be: they'd just collect up all the individual "I need this much" declarations from all the modules, and set the overall size according to the largest value encountered.
Is there any way that the gnu tools can do this sort of thing?