OSDev.org

The Place to Start for Operating System Developers
It is currently Sun Apr 23, 2017 11:32 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 177 posts ]  Go to page Previous  1 ... 8, 9, 10, 11, 12
Author Message
 Post subject: Re: What's your OSDev AWWWW YEAH! moment?
PostPosted: Tue Jan 03, 2017 2:22 am 
Offline
Member
Member
User avatar

Joined: Thu Oct 13, 2016 4:55 pm
Posts: 66
It seems GNU toolchain does not like me, but no worries, it's mutual and I'm not alone :-)

So, did you know that gdb sometimes fails to load symbols from an elf file correctly? What a shame...

I've googled a lot, but all I could find is unanswered questions, a few links:
http://stackoverflow.com/questions/30128561/gdb-sets-breakpoint-on-incorrect-address
http://stackoverflow.com/questions/25333585/gdb-set-a-breakpoint-at-a-wrong-address-for-a-template-function
https://www.sourceware.org/ml/gdb/2004-07/msg00107.html

Here's an example to demonstrate:
Code:
$ objdump -d ps2.so
0000000000000169 <irq1>:
169:   66 b9 00 02             mov    $0x200,%cx
    ....

As you can see, the symbol table is correct in the ELF, irq1 function is at 0x169. Now in gdb:
Code:
(gdb) hbreak irq1
Hardware assisted breakpoint 1 at 0x205081
(gdb) disass *0x205169
No function contains specified address.
(gdb)

Right in the middle of the ELF header... And gdb refuses to disassemble the correct address. Nice, good job GNU developers! (Why can't I disassemble any arbitrary address, btw?)

Anyway if any of you face the same problem, the solution is simple, use 'add-symbol-file' instead of 'symbol-file' and add 0xe8 (the size of the ELF header) to the relocation address:
Code:
(gdb) add-symbol-file bin/root/lib/sys/input/ps2.so 0x2050e8
add symbol table from file "bin/root/lib/sys/input/ps2.so" at
   .text_addr = 0x2050e8
(y or n) y
Reading symbols from bin/root/lib/sys/input/ps2.so...(no debugging symbols found)...done.
(gdb) hbreak irq1
Hardware assisted breakpoint 1 at 0x205169
(gdb) disass irq1
Dump of assembler code for function irq1:
       ...

Hope this saves someone a big headache some day.

Happy debugging!


Top
 Profile  
 
 Post subject: Re: What's your OSDev AWWWW YEAH! moment?
PostPosted: Tue Jan 03, 2017 2:47 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 2709
Location: Chichester, UK
Before complaining about your toolchain you should learn to use it.

The "x" command allows you to disassemble at any address, even when the result is meaningless. The "disassemble" command is used to disassemble functions.


Top
 Profile  
 
 Post subject: Re: What's your OSDev AWWWW YEAH! moment?
PostPosted: Tue Jan 03, 2017 5:01 am 
Offline
Member
Member
User avatar

Joined: Thu Oct 13, 2016 4:55 pm
Posts: 66
iansjack wrote:
Before complaining about your toolchain you should learn to use it.

The "x" command allows you to disassemble at any address, even when the result is meaningless. The "disassemble" command is used to disassemble functions.

Maybe it passed your attention, but my complain was about gdb loading incorrect addresses from an elf. And yes, I know x/i works and thanks, I know GNU toolchain pretty well. It's just I haven't used in the last decade. Haven't changed much. It's the same non-intuitive bastard as it was back in my college days. One would expect that the command "disassemble" disassembles, but no. I've used many different systems, many different compilers, assemblers and linkers, and GNU is still the worst of all. Too bad that's the de facto standard. But I'm not surprised, the PC was always about the worst choices. But that's off topic.
I wrote that post so that people having the same issue could find it with google and have an "AWW YEAH!" moment. That's all.


Top
 Profile  
 
 Post subject: Re: What's your OSDev AWWWW YEAH! moment?
PostPosted: Tue Jan 03, 2017 5:19 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 2709
Location: Chichester, UK
Quote:
Why can't I disassemble any arbitrary address, btw?
If you can find better software then use it.


Top
 Profile  
 
 Post subject: Re: What's your OSDev AWWWW YEAH! moment?
PostPosted: Tue Jan 03, 2017 4:28 pm 
Offline
Member
Member

Joined: Thu May 06, 2010 4:34 am
Posts: 96
Location: Leiden, The Netherlands
This:
Image

_________________
posnk ( a simple unix clone ) homepage & source doc (WIP)
posnk forum thread
posnk status:
- Rewriting VFS to be less braindead and more OO
- Migrating to a better build system


Top
 Profile  
 
 Post subject: Re: What's your OSDev AWWWW YEAH! moment?
PostPosted: Thu Jan 05, 2017 5:59 am 
Offline
Member
Member
User avatar

Joined: Thu Oct 13, 2016 4:55 pm
Posts: 66
And AWWW YEAH! Finally symbol lookup works!
Attachment:
oszdbg.png
oszdbg.png [ 16.77 KiB | Viewed 512 times ]

It first tries to locate dynsym, and if that fails, it fallbacks to symtab. So it's bulletproof :-) :-) :-)


Top
 Profile  
 
 Post subject: Re: What's your OSDev AWWWW YEAH! moment?
PostPosted: Thu Jan 05, 2017 8:08 am 
Offline
Member
Member

Joined: Wed Mar 30, 2011 12:31 am
Posts: 211
Image

A working native gcc 6.3!

Image

And I can build Python extensions with it!

_________________
github | twitter | とあるOS | PonyOS 4.0


Top
 Profile  
 
 Post subject: Re: What's your OSDev AWWWW YEAH! moment?
PostPosted: Wed Jan 11, 2017 1:46 am 
Offline
Member
Member
User avatar

Joined: Tue Jan 10, 2017 3:19 pm
Posts: 84
klange wrote:
Image

A working native gcc 6.3!

Image

And I can build Python extensions with it!


now compile a OS with it to be the only one to finish the challenge of making a OS self hosting then building a OS with that.

_________________
(not so frequently updated) Code is at:

https://github.com/NunoLava1998/DixiumOS-1


Top
 Profile  
 
 Post subject: Re: What's your OSDev AWWWW YEAH! moment?
PostPosted: Wed Jan 11, 2017 3:34 am 
Offline
Member
Member

Joined: Sun Feb 01, 2009 6:11 am
Posts: 1050
Location: Germany
DixiumOS wrote:
now compile a OS with it to be the only one to finish the challenge of making a OS self hosting then building a OS with that.

I don't think Python will be particularly helpful in this challenge.

And he isn't the first or even only one to have a self-hosting OS, but I would assume he's already there.

_________________
Developer of tyndur - community OS of Lowlevel (German)


Top
 Profile  
 
 Post subject: Re: What's your OSDev AWWWW YEAH! moment?
PostPosted: Wed Jan 11, 2017 1:29 pm 
Offline
Member
Member
User avatar

Joined: Tue Jan 10, 2017 3:19 pm
Posts: 84
Kevin wrote:
DixiumOS wrote:
now compile a OS with it to be the only one to finish the challenge of making a OS self hosting then building a OS with that.

I don't think Python will be particularly helpful in this challenge.

And he isn't the first or even only one to have a self-hosting OS, but I would assume he's already there.


"Woo, a working gcc 6.2!"
It's not python

_________________
(not so frequently updated) Code is at:

https://github.com/NunoLava1998/DixiumOS-1


Top
 Profile  
 
 Post subject: Re: What's your OSDev AWWWW YEAH! moment?
PostPosted: Thu Jan 12, 2017 3:25 am 
Offline
Member
Member

Joined: Sun Feb 01, 2009 6:11 am
Posts: 1050
Location: Germany
What he demonstrated isn't really gcc, but that he updated his gcc and used it to build a Python module.

Getting just gcc to work is easier than Python (and just some Python is easier than dynamically loading a module in Python).

_________________
Developer of tyndur - community OS of Lowlevel (German)


Top
 Profile  
 
 Post subject: Re: What's your OSDev AWWWW YEAH! moment?
PostPosted: Thu Jan 12, 2017 4:39 am 
Offline
Member
Member
User avatar

Joined: Tue Jan 10, 2017 3:19 pm
Posts: 84
Kevin wrote:
What he demonstrated isn't really gcc, but that he updated his gcc and used it to build a Python module.

Getting just gcc to work is easier than Python (and just some Python is easier than dynamically loading a module in Python).


No, i meant the ToaruOS developer should compile ToaruOS in gcc.

Y'know, that FIVE star challenge.

_________________
(not so frequently updated) Code is at:

https://github.com/NunoLava1998/DixiumOS-1


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 177 posts ]  Go to page Previous  1 ... 8, 9, 10, 11, 12

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group