Page 12 of 12

Re: What's your OSDev AWWWW YEAH! moment?

Posted: Tue Jan 03, 2017 2:22 am
by bzt
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/3012 ... ct-address
http://stackoverflow.com/questions/2533 ... e-function
https://www.sourceware.org/ml/gdb/2004-07/msg00107.html

Here's an example to demonstrate:

Code: Select all

$ 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: Select all

(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: Select all

(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!

Re: What's your OSDev AWWWW YEAH! moment?

Posted: Tue Jan 03, 2017 2:47 am
by iansjack
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.

Re: What's your OSDev AWWWW YEAH! moment?

Posted: Tue Jan 03, 2017 5:01 am
by bzt
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.

Re: What's your OSDev AWWWW YEAH! moment?

Posted: Tue Jan 03, 2017 5:19 am
by iansjack
Why can't I disassemble any arbitrary address, btw?
If you can find better software then use it.

Re: What's your OSDev AWWWW YEAH! moment?

Posted: Tue Jan 03, 2017 4:28 pm
by Peterbjornx
This:
Image

Re: What's your OSDev AWWWW YEAH! moment?

Posted: Thu Jan 05, 2017 5:59 am
by bzt
And AWWW YEAH! Finally symbol lookup works!
oszdbg.png
It first tries to locate dynsym, and if that fails, it fallbacks to symtab. So it's bulletproof :-) :-) :-)

Re: What's your OSDev AWWWW YEAH! moment?

Posted: Thu Jan 05, 2017 8:08 am
by klange
Image

A working native gcc 6.3!

Image

And I can build Python extensions with it!

Re: What's your OSDev AWWWW YEAH! moment?

Posted: Wed Jan 11, 2017 1:46 am
by DixiumOS
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.

Re: What's your OSDev AWWWW YEAH! moment?

Posted: Wed Jan 11, 2017 3:34 am
by Kevin
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.

Re: What's your OSDev AWWWW YEAH! moment?

Posted: Wed Jan 11, 2017 1:29 pm
by DixiumOS
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

Re: What's your OSDev AWWWW YEAH! moment?

Posted: Thu Jan 12, 2017 3:25 am
by Kevin
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).

Re: What's your OSDev AWWWW YEAH! moment?

Posted: Thu Jan 12, 2017 4:39 am
by DixiumOS
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.

Re: What's your OSDev AWWWW YEAH! moment?

Posted: Sun Jul 02, 2017 1:18 am
by SpyderTL
AWWWW YEAH!

Software triangle rendering with vertex color and interpolation... Done!
Triangle.jpg
Next, make it spin!

I actually already have spinning color vertex triangles in hardware accelerated 3D in VMWare, so now I just need to make the interfaces identical so that I can switch between the two...