How is printf auto-static yoinking of symbols supposed to interact with things like function pointers ? #797
GabrielRavier
started this conversation in
General
Replies: 1 comment 5 replies
-
I haven't tried this, you may be able to force The only official cosmopolitan method I know of is building with Lines 365 to 397 in f7ff77d __STRICT_ANSI__ , _weaken is set as follows: #define _weaken(symbol) symbol https://github.com/jart/cosmopolitan/blob/6f7d0cb1c3962f7cb474b04de75df7cd82a3e5d3/libc/intrin/weaken.h
|
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Having spent a little while studying how the auto-linking in printf works, I'd like to ask if the fact that it simply doesn't work with function pointers is deliberate behavior or effectively a bug.
In particular, a program such as this:
simply doesn't work under cosmopolitan because it never links in
__fmt_dtoa
, as the invocation ofprintf_ptr
cannot be scanned for that purpose. That appears to be deliberate (at least, blog posts such as this one directly indicate that non-direct invocations of printf disable the auto-STATIC_YOINK
mechanism), but I'm wondering if there's any way of disabling that behavior, through a command-line switch to gcc when compiling or something like that.In particular, I'm asking this because I'm currently developing a libc testsuite over here (that's why I've filed 17 bug reports in just a few days), and tests such as this one explicitly test that printf works properly when called through a function pointer.
Right now it's not too much hassle to add in a
but it feels a bit weird to do so, especially as this still means perfectly standards-conforming programs still fail to run properly unless the manual
STATIC_YOINK
is present.I suppose that could just be added to the list of ways in which cosmopolitan deliberately deviates from the standard, but for this in particular it seems odd that there is no way of disabling this behavior.
Beta Was this translation helpful? Give feedback.
All reactions