why not objcopy (generate the ELF directly), xxd --include and such. Why reinvent existing thing? At least grab their relevant piece of code, or stick to their syntax people already know.
-
-
Replying to @elazarl @sortiecat
There are very very good reasons not to do the objcopy stuff. It's an awful hack that should be forgotten except as reminder not to reinvent it.
1 reply 0 retweets 2 likes -
Replying to @RichFelker @sortiecat
Can you please explain more? I liked the idea, since the old C compiler collapsed when I gave him a very long static array. Resorted to asm .data
1 reply 0 retweets 0 likes -
Replying to @elazarl @sortiecat
Asm .data is less awful than objcopy, but still nonportable and inherently hides the content of the data from the compiler (preventing static analysis of correctness aspects and value range based optimization).
1 reply 1 retweet 1 like -
Can't find the thread at the moment, but it was recently discussed that huge array blows up gcc's ast but huge string avoids it. Ugly but works.
2 replies 0 retweets 0 likes -
I should say huge initializer list rather than single string-literal initializer. It's an array either way.
1 reply 0 retweets 0 likes -
Replying to @RichFelker @sortiecat
So the problem is objcopy hiding the content from the compiler? Why? What about LTO? Why does it matter for a big static array? Which optimizations do you expect?
2 replies 0 retweets 0 likes -
Replying to @elazarl @sortiecat
Re: hiding, yes. I already mentioned static analysis & value range based optimization.
1 reply 0 retweets 0 likes -
Dumb example: if it's a bitrot table and your rotate operation is safe against out-of-range values, by seeing the table contents are all in-range the compiler can optimize out the range reduction.
1 reply 0 retweets 0 likes -
Replying to @RichFelker @sortiecat
I don't see how this kind of table would be generated from a binary file. Also, can probably be still done with LTO. Or maybe I didn't get the example.
1 reply 0 retweets 0 likes
Rich Felker Retweeted Rich Felker
LTO doesn't work at that level (only on compiler's LTO IR) and there are fundamental difficulties trying to make it work on that level. See this thread:https://twitter.com/RichFelker/status/1009284296216141825 …
Rich Felker added,
-
-
I agree it's a dumb example, but you can imagine examples where the data is something like signed values that are all positive or that never achieve the minimum value (which is pathological in some ways).
1 reply 0 retweets 0 likes -
Replying to @RichFelker @sortiecat
I agree that LTO can't work on compiled code in general, but we're taking here on a static char array. LTO'ing that should be at at least possible.
0 replies 0 retweets 0 likes
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.