LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-07-2011, 12:15 PM   #1
lee_can
Member
 
Registered: Mar 2011
Posts: 118

Rep: Reputation: 1
Linux GCC - Compiling using static


Hi all,
i am trying to follow on of the tutorial on a linux system
when i want to compile a small program dont by writing:
gcc -static - o exit exit.c
i got this:
Code:
/usr/lib/gcc/i486-linux-gnu/4.3.2/../../../../lib/libc.a(elf-init.o): In function `__libc_csu_irel':
(.text+0xe5): undefined reference to `__rel_iplt_end'
/usr/lib/gcc/i486-linux-gnu/4.3.2/../../../../lib/libc.a(elf-init.o): In function `__libc_csu_irel':
(.text+0xec): undefined reference to `__rel_iplt_start'
/usr/lib/gcc/i486-linux-gnu/4.3.2/../../../../lib/libc.a(elf-init.o): In function `__libc_csu_irel':
(.text+0xfd): undefined reference to `__rel_iplt_start'
/usr/lib/gcc/i486-linux-gnu/4.3.2/../../../../lib/libc.a(elf-init.o): In function `__libc_csu_irel':
(.text+0x106): undefined reference to `__rel_iplt_start'
/usr/lib/gcc/i486-linux-gnu/4.3.2/../../../../lib/libc.a(elf-init.o): In function `__libc_csu_irel':
(.text+0x113): undefined reference to `__rel_iplt_start'
/usr/lib/gcc/i486-linux-gnu/4.3.2/../../../../lib/libc.a(elf-init.o): In function `__libc_csu_irel':
(.text+0x11b): undefined reference to `__rel_iplt_start'
collect2: ld returned 1 exit status
Can anyone advise?
thanks in advance
 
Old 08-07-2011, 04:15 PM   #2
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,093

Rep: Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474
Quote:
i am trying to follow on of the tutorial on a linux system
posting a link would help greatly
A 5 to 10 year old tutorial on a new OS will not work well

and WHAT operating system are you building this program on that is using the older gcc4.3

and posting the code to this "exit.c" program would help
 
Old 08-08-2011, 12:32 PM   #3
lee_can
Member
 
Registered: Mar 2011
Posts: 118

Original Poster
Rep: Reputation: 1
Thank you John for your reply.

I am following "Buffer Overflow Primer Part 2 (Writing Exit Shellcode)"
http://www.securitytube.net/video/232.

i am using Backtrack 4.
about the code is very simple, it is just very simple code:
Quote:
#include<stdlib.h>
main()
{
exit(0)
}
it is just i cannot compile using: gcc -static -o exit exit.c
Thanks in advance
 
Old 08-08-2011, 12:52 PM   #4
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190
Quote:
Originally Posted by lee_can View Post
about the code is very simple, it is just very simple code
It is not exactly the code you quoted, because the code you quoted was missing a ;

Quote:
it is just i cannot compile using: gcc -static -o exit exit.c
Works for me in version 4.3.2 of gcc (I fixed the missing ;).

So I expect something is installed or configured incorrectly in your gcc 4.3.2

Try
Code:
gcc -v -static -o exit exit.c
That will tell you a lot of detail of the actions gcc goes through to compile (and more importantly link) your program. It might indicate what is going wrong.
 
1 members found this post helpful.
Old 08-08-2011, 01:19 PM   #5
lee_can
Member
 
Registered: Mar 2011
Posts: 118

Original Poster
Rep: Reputation: 1
thanks for your prompt reply
Regarding the ";", it is just i forgot to put it here, sorry for that.
well, this is the output given:
Quote:
gcc -v -static -o exit exit.c
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.3.2-1ubuntu12' --with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.3 --program-suffix=-4.3 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --enable-targets=all --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version 4.3.2 (Ubuntu 4.3.2-1ubuntu12)
COLLECT_GCC_OPTIONS='-v' '-static' '-o' 'exit' '-mtune=generic'
/usr/lib/gcc/i486-linux-gnu/4.3.2/cc1 -quiet -v exit.c -D_FORTIFY_SOURCE=2 -quiet -dumpbase exit.c -mtune=generic -auxbase exit -version -fstack-protector -o /tmp/ccOtX6LE.s
ignoring nonexistent directory "/usr/local/include/i486-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/i486-linux-gnu/4.3.2/../../../../i486-linux-gnu/include"
ignoring nonexistent directory "/usr/include/i486-linux-gnu"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/lib/gcc/i486-linux-gnu/4.3.2/include
/usr/lib/gcc/i486-linux-gnu/4.3.2/include-fixed
/usr/include
End of search list.
GNU C (Ubuntu 4.3.2-1ubuntu12) version 4.3.2 (i486-linux-gnu)
compiled by GNU C version 4.3.2, GMP version 4.2.2, MPFR version 2.3.2.
GGC heuristics: --param ggc-min-expand=64 --param ggc-min-heapsize=63788
Compiler executable checksum: 9ecd6562c106044a1f3a6d56a4b5859b
COLLECT_GCC_OPTIONS='-v' '-static' '-o' 'exit' '-mtune=generic'
as -V -Qy -o /tmp/cc2VVtre.o /tmp/ccOtX6LE.s
GNU assembler version 2.18.93 (i486-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.18.93.20081009
COMPILER_PATH=/usr/lib/gcc/i486-linux-gnu/4.3.2/:/usr/lib/gcc/i486-linux-gnu/4.3.2/:/usr/lib/gcc/i486-linux-gnu/:/usr/lib/gcc/i486-linux-gnu/4.3.2/:/usr/lib/gcc/i486-linux-gnu/:/usr/lib/gcc/i486-linux-gnu/4.3.2/:/usr/lib/gcc/i486-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/i486-linux-gnu/4.3.2/:/usr/lib/gcc/i486-linux-gnu/4.3.2/:/usr/lib/gcc/i486-linux-gnu/4.3.2/../../../../lib/:/lib/../lib/:/usr/lib/../lib/:/usr/lib/gcc/i486-linux-gnu/4.3.2/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-static' '-o' 'exit' '-mtune=generic'
/usr/lib/gcc/i486-linux-gnu/4.3.2/collect2 -m elf_i386 --hash-style=both -static -o exit -z relro /usr/lib/gcc/i486-linux-gnu/4.3.2/../../../../lib/crt1.o /usr/lib/gcc/i486-linux-gnu/4.3.2/../../../../lib/crti.o /usr/lib/gcc/i486-linux-gnu/4.3.2/crtbeginT.o -L/usr/lib/gcc/i486-linux-gnu/4.3.2 -L/usr/lib/gcc/i486-linux-gnu/4.3.2 -L/usr/lib/gcc/i486-linux-gnu/4.3.2/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/i486-linux-gnu/4.3.2/../../.. /tmp/cc2VVtre.o --start-group -lgcc -lgcc_eh -lc --end-group /usr/lib/gcc/i486-linux-gnu/4.3.2/crtend.o /usr/lib/gcc/i486-linux-gnu/4.3.2/../../../../lib/crtn.o
/usr/lib/gcc/i486-linux-gnu/4.3.2/../../../../lib/libc.a(elf-init.o): In function `__libc_csu_irel':
(.text+0xe5): undefined reference to `__rel_iplt_end'
/usr/lib/gcc/i486-linux-gnu/4.3.2/../../../../lib/libc.a(elf-init.o): In function `__libc_csu_irel':
(.text+0xec): undefined reference to `__rel_iplt_start'
/usr/lib/gcc/i486-linux-gnu/4.3.2/../../../../lib/libc.a(elf-init.o): In function `__libc_csu_irel':
(.text+0xfd): undefined reference to `__rel_iplt_start'
/usr/lib/gcc/i486-linux-gnu/4.3.2/../../../../lib/libc.a(elf-init.o): In function `__libc_csu_irel':
(.text+0x106): undefined reference to `__rel_iplt_start'
/usr/lib/gcc/i486-linux-gnu/4.3.2/../../../../lib/libc.a(elf-init.o): In function `__libc_csu_irel':
(.text+0x113): undefined reference to `__rel_iplt_start'
/usr/lib/gcc/i486-linux-gnu/4.3.2/../../../../lib/libc.a(elf-init.o): In function `__libc_csu_irel':
(.text+0x11b): undefined reference to `__rel_iplt_start'
collect2: ld returned 1 exit status
is the problem cause some folder not existing? :
Quote:
ignoring nonexistent directory "/usr/local/include/i486-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/i486-linux-gnu/4.3.2/../../../../i486-linux-gnu/include"
ignoring nonexistent directory "/usr/include/i486-linux-gnu"
but how shall i add these folder automatically?
 
Old 08-08-2011, 03:12 PM   #6
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,093

Rep: Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474
Quote:
i am using Backtrack 4.
before going to far with a 4 ( bt 4 -Jan,2010 or 4 r1 May,2010 or 4r2 Nov.2010 ) install is there a reason you are not using the current 5

backtrack5 was released in may
http://www.backtrack-linux.org/wiki/...hp/Downloading

it builds here on opensuse 11.3 , set to gcc 4.3 ( 4.5 is default )
once i removed the space in your basic build command "gcc -static - o exit exit.c" to gcc -static -o exit exit.c


you might want to install 5

Last edited by John VV; 08-08-2011 at 03:35 PM.
 
1 members found this post helpful.
Old 08-08-2011, 03:54 PM   #7
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190
Quote:
Originally Posted by lee_can View Post
is the problem cause some folder not existing? :
No. Those messages are OK.

My -v suggestion did not give the useful results I hoped for.

A google search for the error you reported hits lots of discussion of the bug, but not any discussion I understand. I can't tell if it is a bug in ld itself or in a script fed to ld or what. I also can't tell what versions of what software have the bug.

John VV's suggestion (switch to newer software) might be the only way forward for a non expert Linux user faced with a confusing bug.

I think the problem must be in the build of binutils (not GCC). I don't know if it is in the version of binutils or more specific (to the Linux distribution).

Changing to a newer gcc probably wouldn't help. I'm pretty sure the bug is independent of the version of gcc. If you can change to a newer binutils within backtrack 4, I expect that would help. Changing to backtrack 5 is more likely to help.

Last edited by johnsfine; 08-08-2011 at 03:59 PM.
 
Old 08-12-2011, 11:36 AM   #8
lee_can
Member
 
Registered: Mar 2011
Posts: 118

Original Poster
Rep: Reputation: 1
Thanks a lot John VV & johnsfine for your help.
Well, i tried before on backtrack 5, and everything was normal and work nicely.

The issue why i am not using Backtrack 5 is that still i am having some problem with it, like sounds, etc,,,

But i will give a try to remove the old version of gcc and to install the updated one.

thanks againa guys for your help.

*Edit*
Well, after downloading latest version, i tried to read some paper on how to install gcc, i think it is so complicated is it correct?
This is the link which i used:
http://gcc.gnu.org/install/

Last edited by lee_can; 08-12-2011 at 12:38 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
compiling linux kernel 2.4 using gcc-4.1 isalmbio Linux - Kernel 4 06-18-2007 01:29 PM
compiling linux kernel 2.4 using gcc-4.1 isalmbio Debian 1 06-17-2007 01:36 PM
wich is the best gcc for compiling the linux kernel??? Claus Linux - Software 1 09-01-2003 09:15 AM


All times are GMT -5. The time now is 12:51 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration