by muxator · 3y ago · 0 comments
const int main[] __attribute__ ((section(".text"))) = {
-443987883, 440, 113408, -1922629632,
4149, 899584, 84869120, 15544,
266023168, 1818576901, 1461743468, 1684828783,
-1017312735
};
Compilation (gcc 13): $ gcc -Wall main.c -o main
main.c:1:11: warning: ‘main’ is usually a function [-Wmain]
1 | const int main[] __attribute__ ((section(".text"))) = {
| ^~~~
/tmp/ccsWmdiD.s: Assembler messages:
/tmp/ccsWmdiD.s:4: Warning: ignoring changed section attributes for .text
Execution: $ ./main
Hello World!Although I found that gcc seems to be configured with -pie per default, so this compilation works:
$ gcc -Wall -fno-PIE -no-pie main.c -o main
mainf.c:1:11: warning: ‘main’ is usually a function [-Wmain]
1 | const int main[] __attribute__((section(".text"))) = {
| ^~~~
/tmp/ccq0adwj.s: Assembler messages:
/tmp/ccq0adwj.s:4: Warning: ignoring changed section attributes for .text