On Friday 27 July 2012 19:38:01 Jiří Zárevúcky wrote:
> On 27 July 2012 18:46, Martin Sucha <[email protected]> wrote:
> > [...]
> > 
> > Anyway, I think the proper solution is to correctly replace function
> > names in the sources that need the substitution to occur, but I can't
> > think of a way to achieve this using the C preprocessor. Maybe we could
> > use a wrapper around the C preprocessor to add the posix_ prefix where
> > necessary instead of adding it using defines?
> 
> Another solution would be to provide symbol aliases instead of
> preprocessor defines. That's the cleanest way I can think of, but it
> would require libc symbols of the same names to be declared weak. That
> is not a problem if we consider libc and libposix to be developed in
> tandem. Using preprocessor for this kind of task is *really* messy (I
> never liked it).

I have very little experience in this area, but wouldn't it mean that we 
cannot link code using libc and libposix into a single binary (as libposix 
symbols would override libc symbols)? Also, will this work when using dynamic 
linking? 

According to ELF specification, an undefined weak symbol does not generate an 
error message, but is instead set to zero. This could make debugging harder if 
you forget about it (a run-time error instead of link-time error).

On the other hand, changing symbols at the object level could work even if the 
code contains references to posix functions e.g. in inline assembler, not just 
only in C code. What do you think about patching the compiled object files to 
reference correct symbols before linking, instead of using weak symbols?

Regards,
Martin Sucha


_______________________________________________
HelenOS-devel mailing list
[email protected]
http://lists.modry.cz/cgi-bin/listinfo/helenos-devel

Reply via email to