LinuxQuestions.org
Review your favorite Linux distribution.
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 09-15-2003, 03:12 AM   #1
Baran
Member
 
Registered: Aug 2003
Location: Tampere-FINLAND
Distribution: Mandrake 10.1
Posts: 105

Rep: Reputation: 15
ELF header trouble great! :(


The story of the trouble is long...

Two days ago I tried to install MATLAB R13 on my Red Hat 9.0 machine. It was going right until the install GUI crashed under KDE. I turn off the computer, the next time I tried to boot linux, I had errors, like this...


...
date: cannot load /lib/librt.so.1 no such file or command
...
sleep:cannot load /lib/librt.so.1 no such file or command
...

Linux boots, however X is not available. Afterward I went to directort /lib to look at the file librt.so.1 , therewas !librt.so.1 there. Fortunately I was using Midnight Commander, it was writing that, !librt.so.1 is a broken symbolic link to lijrt.2-3-2.so , I found that there isn't file like lijrt.2-3-2.so but there was one which is librt.2-3-2.so, I thought that this should be the link so I created a file named librt.so.1 which is a symbolic link to librt.2-3-2.so. I thought that I was doing the right. However when I reboot my system, this time I got such errors

...
date: cannot load /lib/librt.so.1 invalid ELF header
...
sleep: cannot load /lib/librt.so.1 invalid ELF header
...

System boot again but without X, I then thought that it should wise to install ELF-devels from the RedHat9.0 installation CDs, I found some files like elfutils, elf-devels, like things anyways, when I wrote...

rpm -ivh elf-devels.....

I got this error:

rpm: cannot load /lib/librt.so.1 invalid ELF header

Now I am stuck to this ELF header business, what should I do?
 
Old 09-15-2003, 03:58 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529
I thought that this should be the link so I created a file named librt.so.1 which is a symbolic link to librt.2-3-2.so. I thought that I was doing the right.

If you don't know if what you're doing, experimenting til it breaks is cool :-] Running (as root): "rpm -qf /lib/librt.so.1" shows it's part of the Glibc rpm. There's two ways to fix this, and that's manually linking librt.2-3-2.so to librt.so.1 or force reinstalling the package. Sure there's more ways like extracting and running the scripts part of the rpm and running ldconfig could update the links as well.
If you opt for reinstalling the rpm you don't have to, else run ldconfig to update the library cache after you're done.
 
Old 09-15-2003, 04:05 AM   #3
Baran
Member
 
Registered: Aug 2003
Location: Tampere-FINLAND
Distribution: Mandrake 10.1
Posts: 105

Original Poster
Rep: Reputation: 15
But I cannot run rpm command, I tried this just to test if I can use it

rpm -qa

just this command gace the same error

rpm: cannot load /lib/librt.so.1 invalid ELF header

I mean I cannot install any rpms

I tried ldconfig as well, it says

ldconfig:there is no such file or command

they told me that ldconfig comes with glibc package this must be installed, but I guess I don't have that

say something I don't want to reinstall all the system...
 
Old 09-15-2003, 04:10 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529
Have the rpms ready (ftp 'em from a local RH mirror or like that) and run rpm from the RH bootdisk/cdr.
 
Old 09-15-2003, 04:14 AM   #5
Baran
Member
 
Registered: Aug 2003
Location: Tampere-FINLAND
Distribution: Mandrake 10.1
Posts: 105

Original Poster
Rep: Reputation: 15
I don't know if this is the same thing:

I boot the system with installation CD-ROM, there is a rescue option there, so I did that, afterwards,

chroot /mnt/sysimage (it was saying that this is my system)

then I tried rpm again, but I had the same error, I can try from a bootdisk also, but I think it is same, isn't it?
 
Old 09-15-2003, 05:14 AM   #6
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529
Yeah it's the same. Boot the rescue cdr and point rpm to use the database on the disk. It should work. If it doesn't post the exact commands and errors you got. One way to get these in one file is to start a logging session using "script <filename>" (make file is on a writable disk, not the cdr). When you're done type "exit" to exit "script". Make sure you edit out any control commands and other garbage before you post the logfile.
 
Old 09-15-2003, 05:17 AM   #7
Baran
Member
 
Registered: Aug 2003
Location: Tampere-FINLAND
Distribution: Mandrake 10.1
Posts: 105

Original Poster
Rep: Reputation: 15
thank you for your help, unfortunately I can do that tomorrow
I wish you will be around
 
Old 09-15-2003, 05:18 AM   #8
Baran
Member
 
Registered: Aug 2003
Location: Tampere-FINLAND
Distribution: Mandrake 10.1
Posts: 105

Original Poster
Rep: Reputation: 15
I am sorry I forget to ask, what does this mean:

"Boot the rescue cdr and point rpm to use the database on the disk"
 
Old 09-15-2003, 05:44 AM   #9
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529
Rpm has a flag "--root" you use to tell it where the rpm databases are, because the ones you want to use are not on the cdr.
Btw, did you try manually linking librt?
 
Old 09-15-2003, 05:49 AM   #10
Baran
Member
 
Registered: Aug 2003
Location: Tampere-FINLAND
Distribution: Mandrake 10.1
Posts: 105

Original Poster
Rep: Reputation: 15
yes I can manually link librt. In fact I tried it already, I wrote it in the first massage, I got that ELF header errors after I linked that. Before I made the link, it was saying that there isn't such file or command...

I guess what you are telling is

rpm --root <my database>

but where is my database?

I am sorry I still don't know enough about linux
 
Old 09-16-2003, 03:12 AM   #11
Baran
Member
 
Registered: Aug 2003
Location: Tampere-FINLAND
Distribution: Mandrake 10.1
Posts: 105

Original Poster
Rep: Reputation: 15
I got the exact error at the boot:

/bin/date: error while loading shared library
libraries: librt.so.1 cannot open shared object file: No such file or directory

after that booting goes on, and the when the system is done, X doesn't start instead I get this:

INIT: Id "x" respawning too fast: diabled for 5 minutes




Up to now I tried these:
1) I manually created link for librt.so.1 to librt-2.3.2.so because when I look at file information for librt.so.1, it was saying that it is a broken link to lijrt-2.3.2.so so I thought it should be librt-2.3.2.so

2)Then I tried /bin/date again
[root@localhost root]# /bin/date
/bin/date: error while loading shared libraries: /lib/librt.so.1 : invalid ELF header

3) then
[root@localhost root]# ldconfig
ldconfig: /lib/librt-2.3.2.so is not an ELF file-it has the wrong magic bytes at the start
/lib/librt.so.1 is not an ELF file-it has the wrong magic bytes at the start
usr/lib/librt.so is not an ELF file-it has the wrong magic bytes at the start

I then thought that I may be massing things up and modified the librt.so.1 as it were before linking lijrt-2.3.2.so, afterwards


4) Boot from CD, then

bash-2.05b# ldconfig -r /mnt/sysimage
ldconfig: /lib/librt-2.3.2.so is not an ELF file-it has the wrong magic bytes at the start

5)
bash-2.05b# rpm --root /mnt/sysimage -qf /mnt/sysimage/lib/librt-2.3.2.so
file /mnt/sysimage/lib/librt-2.3.2.so is not owned by any package

6) I tried these also
bash-2.05b# rpm --root /mnt/sysimage --force -ivh elfutils-libelf-0.76-3.i386.rpm
/sbin/ldconfig: /lib/librt-2.3.2.so is not an ELF file-it has the wrong magic bytes at the start
rpm db:/var/lib/rpm/Triggername: No such file or directory
rpm db:/var/lib/rpm/Triggername: cannot sync:No such file or directory
error:db4 error(2) from dbenv-> close: No such file or directory


I guess I wrote everything...

what can be done now?
 
Old 09-16-2003, 08:01 AM   #12
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529
//First of all you shouldnt crosspost your questions. I can imagine you need it fixed fast, but crossposting is bad netiquette, a waste of time for LQ members and respectless towards those who provide you with resources (LQ, Jeremy, that is). Bump your thread if you need to instead of crossposting. If still impatient, consider supporting the Linux cause by hiring a local Linux guru.

That said, first open up /etc/inittab and change the "5" in the line starting with "id:5:initdefault:" to "3": "id:3:initdefault:". This will load up the system in *single user* mode to prevent loading X while you work out your solution and you won't get hassled with the "INIT: Id "x" respawning too fast: diabled for 5 minutes" messages.
Execute "telinit 3" to enter runlevel 3. Make sure you stop any network services you don't need to provide right now ("chkconfig --list").

I guess what you are telling is
rpm --root <my database>
but where is my database?

Should be the /var/lib/rpm dir (do an "ls -al" on it to see).

I am sorry I still don't know enough about linux
No prob. That's what LQ is here for.

For any of the commands below (between quotes), if you can't run them, boot the Red Hat cd in rescue mode: do not make it boot your Red Hat on your harddisk.

1) I manually created link for librt.so.1 to librt-2.3.2.so because when I look at file information for librt.so.1, it was saying that it is a broken link to lijrt-2.3.2.so so I thought it should be librt-2.3.2.so
I don't know any library called "lijrt-2.3.2.so", "ln -sf /lib/librt-2.3.2.so /lib/librt.so.1" should do.

2)Then I tried /bin/date again
Of course that should not work, it isnt fixed yet.

3) ldconfig: /lib/librt-2.3.2.so is not an ELF file-it has the wrong magic bytes at the start
Fsck! Corrupted library. Last ditch effort, gotta extract from rpm and restore manually before running ldconfig.
Locate your Glibc rpm, I'm using glibc-2.3.2.i386.rpm as example:
"mkdir /var/tmp/glibc; cd /var/tmp"
"rpm2cpio glibc-2.3.2.i386.rpm > glibc-2.3.2.cpio"
"mv glibc-2.3.2.cpio glibc/; cd glibc"
"cpio --make-directories --force-local --extract --no-absolute-filenames --no-preserve-owner --verbose -F glibc-2.3.2.cpio"
"cp -f lib/librt-2.3.2.so /lib; ln -sf /lib/librt-2.3.2.so /lib/librt.1.so"
(don't know if necessary: "ln -sf /lib/librt.1.so /lib/librt.so")
"rm -rf /var/tmp/glibc"
Now run "ldconfig" (from cd if you cant make it work).
Then running "ldconfig -p|grep librt" should show the libraries.

If it works you should "refresh" the glibc rpm to be consistent with the database. I guess this means you'll have to use --force to update it with the same version.


4) Boot from CD, then
ldconfig -r /mnt/sysimage

Wasn't fixed yet, right?

5) rpm --root /mnt/sysimage -qf /mnt/sysimage/lib/librt-2.3.2.so
file /mnt/sysimage/lib/librt-2.3.2.so is not owned by any package

Shouldn't that be "rpm --root /mnt/sysimage -qf /lib/librt-2.3.2.so"?

6) I tried these also
rpm --root /mnt/sysimage --force -ivh elfutils-libelf-0.76-3.i386.rpm

AFAIK librt isnt in elfutils-libelf...

rpm db:/var/lib/rpm/Triggername: No such file or directory
rpm db:/var/lib/rpm/Triggername: cannot sync:No such file or directory
error:db4 error(2) from dbenv-> close: No such file or directory

Auch! List your (/mnt/sysimage)/var/lib/rpm and check for temporary files (starting with two underscores AFAIK)
"ls -al /var/lib/rpm".
if errors persist, make a backup copy of /var/lib/rpm and rebuild the database with "rpm --rebuilddb".


Hope this helps, if any errors occur, be sure to post the output and the commands leading up to it. One way to have 'em all in one file is to run your session under "script": login and run "script </path/to/filename>". If you boot the cdr, then make sure the logfile goes to a readable dir like /mnt/sysimage/tmp.
Be aware the "script" logfile also logs control chars, scrub them before you post any lines.
 
Old 09-17-2003, 07:43 AM   #13
Baran
Member
 
Registered: Aug 2003
Location: Tampere-FINLAND
Distribution: Mandrake 10.1
Posts: 105

Original Poster
Rep: Reputation: 15
Did anyone said you are a great man unSpawn? I tried what you have said. Then everything started working as before. The solution was easier then I have imagined, however I learned that understanding the problem is much more harder sometimes.
Thank you for everything. By the way about the crossposting business: I didn't think that this would be a bad thing, I thought that the threads were listed according to their first date of post, this thread was on the third page when I wrote a new thread. But I then realised that a thread becomes the first one on the list when a new post is send, however it was so late, I had already sent the new thread which was the same. If I had known that the procedure was like this, I wouldn't do that. I am sorry again.

One suggestion: I tried to erase the second thread but I couldn't manage to do that. I guess there must such an option, owner of the tread should be able to erase his/her tread.

Take good care...
 
Old 09-17-2003, 08:20 AM   #14
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529
Did anyone said you are a great man unSpawn?
No, and I just ain't, LOL.

The solution was easier then I have imagined, however I learned that understanding the problem is much more harder sometimes.
Just try to formulate your problem clearly, find out the dependencies and test each part of the equation. If you do that in a methodical way then you'll definately get better at troubleshooting.

One suggestion: I tried to erase the second thread but I couldn't manage to do that. I guess there must such an option, owner of the tread should be able to erase his/her tread.
LQ doesn't allow members to delete threads or posts. Only thing you can do is edit out the text from the post and call for a mod to close the thread. Only root (Jeremy) can delete threads, and he will only do that if it is in violation of the LQ rules.
 
Old 09-17-2003, 10:22 AM   #15
Baran
Member
 
Registered: Aug 2003
Location: Tampere-FINLAND
Distribution: Mandrake 10.1
Posts: 105

Original Poster
Rep: Reputation: 15
OK then unSpawn, next time when I want to delete my thread I will call you
 
  


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
"invalid Elf header" after kernel upgrade Goo Slackware 7 10-09-2004 09:32 AM
Invalid ELF header when using Automake/Autoconf Zotty Programming 1 09-17-2004 02:23 PM
snes9x lib and ELF header issues jasondcater Linux - Games 2 05-13-2004 06:28 PM
libpcre invalid ELF header error. geoffd4 Linux - Software 0 05-10-2004 10:30 PM
a great trouble about tcp/ip dowin Programming 0 11-12-2001 09:14 PM


All times are GMT -5. The time now is 10:40 AM.

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