On Tue, Aug 24, 2021 at 08:04:46PM +1000, G. Branden Robinson wrote: > At 2021-08-24T11:50:57+0200, Michael Kerrisk (man-pages) wrote: > > On 8/23/21 11:01 PM, наб wrote: > > > -option is given > > > -.BR and > > > -the header > > > -.I <alloca.h> > > > -is not included. > > > -Otherwise, (without an \-ansi or \-std=c* option) the glibc version of > > > -.I <stdlib.h> > > > -includes > > > +are specified, in which case > > > .I <alloca.h> > > > -and that contains the lines: > > > +is required, lest an actual symbol dependency is emitted. > > (That last line seems like a useful addition!) > I agree, but I note that the verb should be in the subjunctive mood. Not a clue what this means, but the "is" should be "be", I do agree. > Also, is the word "actual" doing any work here? Dunno; without standards conformance (-ansi, -std=c*) alloca() is a magical identifier, in that, if you compile this: -- >8 -- extern void * alloca(unsigned long s); int main() { alloca(20); puts("200"); } -- >8 -- You get -- >8 -- nabijaczleweli@tarta:~/uwu$ cc a.c -oa.o -c a.c:4:2: warning: implicit declaration of function 'puts' is invalid in C99 [-Wimplicit-function-declaration] puts("200"); ^ 1 warning generated. nabijaczleweli@tarta:~/uwu$ readelf -s a.o Symbol table '.symtab' contains 6 entries: Num: Value Size Type Bind Vis Ndx Name 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND 1: 0000000000000000 0 FILE LOCAL DEFAULT ABS a.c 2: 0000000000000000 0 SECTION LOCAL DEFAULT 2 3: 0000000000000000 0 SECTION LOCAL DEFAULT 4 4: 0000000000000000 33 FUNC GLOBAL DEFAULT 2 main 5: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND puts -- >8 -- and if you drop the -c, it will link, run, and print "200". If you do request standards conformance, however, -- >8 -- nabijaczleweli@tarta:~/uwu$ cc a.c -oa.o -c -std=c18 a.c:4:2: warning: implicit declaration of function 'puts' is invalid in C99 [-Wimplicit-function-declaration] puts("200"); ^ 1 warning generated. nabijaczleweli@tarta:~/uwu$ readelf -s a.o Symbol table '.symtab' contains 7 entries: Num: Value Size Type Bind Vis Ndx Name 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND 1: 0000000000000000 0 FILE LOCAL DEFAULT ABS a.c 2: 0000000000000000 0 SECTION LOCAL DEFAULT 2 3: 0000000000000000 0 SECTION LOCAL DEFAULT 4 4: 0000000000000000 35 FUNC GLOBAL DEFAULT 2 main 5: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND alloca 6: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND puts -- >8 -- and, trivially, -- >8 -- nabijaczleweli@tarta:~/uwu$ cc a.c -oa -std=c18 a.c:4:2: warning: implicit declaration of function 'puts' is invalid in C99 [-Wimplicit-function-declaration] puts("200"); ^ 1 warning generated. /bin/ld: /tmp/a-935faa.o: in function `main': a.c:(.text+0xa): undefined reference to `alloca' clang: error: linker command failed with exit code 1 (use -v to see invocation) -- >8 -- C compilers are fully allowed to do magic, and this is some of this magic: unless in ISO mode, it's impossible to ODR-use alloca(). > Thus: > [[ > is required, lest a symbol dependency be emitted. > ]] Sure. Best, наб
Attachment:
signature.asc
Description: PGP signature