ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I need a program that do nothing !
it must contains only a return to the caller.
like iefbr14 on ibm mainframes.....: an assembler pgm containing a branch to register 14,a return to the caller...
i 'm a linux newbie,but not a computer newbie,i immagine kde is written in
C language,so if someone know where to download an alreday compiled C
pgm that "do nothing" or have patience to instruct me to write correct statements and issue the make and/or make install command ,i will reach my target.
thanks in advance
Maurizio
void main() {return;} or simply void main() {} would do the trick... however, in Linux a program is suppose to return 0 or an error code apon completion of it's execution to truly follow all the rules.
Also... so you know... KDE is written in C++ utilizing the QT API.
I compiled this without any optimizations.. using -O3 or -Os would produce less code.
woo!! that was nice... thanks for posting that jtshaw!!!
for me what was also interesting is that both executables had the same size with the default compilation: 4355
Hi
First :thanks to all people that answered to my question.
i was using the dummy pgm in the mainframe environment to
reach this target...
immagine a product that starts many other pgm that may be uneseful.
the program starting is not ruled by parameters...
so i renamed the dummy pgm with the name of the original to be substituted...
the iefbr14 contains a return to register 14,then the return code is 0
because the operation is always successfull.
so the main product think to have started a sub program but instead it starts a dummy.
if the C environment does not provide automatically a return code 0
meaning successfull operation,then the dummy pgm must contain a
return code 0 setting.
The smallest I could get it that would link was ...
If you change languages, you can do better
Code:
13:20 aluser@alf:~/test/asm$ cat small.s
.globl _start
.text
_start:
movl $1, %eax
int $0x80
13:20 aluser@alf:~/test/asm$ as -o small.o small.s
13:20 aluser@alf:~/test/asm$ ld -o small small.o
13:20 aluser@alf:~/test/asm$ ./small
13:20 aluser@alf:~/test/asm$ echo $?
0
13:20 aluser@alf:~/test/asm$ ls -l small
-rwxr-xr-x 1 aluser aluser 656 Sep 1 13:20 small
Obviously, this is specific to linux x86...
It calls the exit() syscall with whatever is in %ebx as the exit value. On my system that happens to be 0.
If you don't call exit from _start, it'll segfault; _start doesn't have a calling function. When you compile something with gcc and it links with libc, libc sets up a _start that calls your main() and exits with main's return code; I've bypassed that step.
I've read it's actually possible to get a working executabe down to the size of the ELF header by putting code in unused parts of the header. You would have to create the entire executable in a hex editor at that point.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.