OSDev.org
https://forum.osdev.org/

What's your OSDev AWWWW YEAH! moment?
https://forum.osdev.org/viewtopic.php?f=11&t=27692
Page 12 of 12

Author:  bzt [ Tue Jan 03, 2017 2:22 am ]
Post subject:  Re: What's your OSDev AWWWW YEAH! moment?

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!

Author:  iansjack [ Tue Jan 03, 2017 2:47 am ]
Post subject:  Re: What's your OSDev AWWWW YEAH! moment?

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.

Author:  bzt [ Tue Jan 03, 2017 5:01 am ]
Post subject:  Re: What's your OSDev AWWWW YEAH! moment?

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.

Author:  iansjack [ Tue Jan 03, 2017 5:19 am ]
Post subject:  Re: What's your OSDev AWWWW YEAH! moment?

Quote:
Why can't I disassemble any arbitrary address, btw?
If you can find better software then use it.

Author:  Peterbjornx [ Tue Jan 03, 2017 4:28 pm ]
Post subject:  Re: What's your OSDev AWWWW YEAH! moment?

This:
Image

Author:  bzt [ Thu Jan 05, 2017 5:59 am ]
Post subject:  Re: What's your OSDev AWWWW YEAH! moment?

And AWWW YEAH! Finally symbol lookup works!
Attachment:
oszdbg.png
oszdbg.png [ 16.77 KiB | Viewed 7197 times ]

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

Author:  klange [ Thu Jan 05, 2017 8:08 am ]
Post subject:  Re: What's your OSDev AWWWW YEAH! moment?

Image

A working native gcc 6.3!

Image

And I can build Python extensions with it!

Author:  DixiumOS [ Wed Jan 11, 2017 1:46 am ]
Post subject:  Re: What's your OSDev AWWWW YEAH! moment?

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.

Author:  Kevin [ Wed Jan 11, 2017 3:34 am ]
Post subject:  Re: What's your OSDev AWWWW YEAH! moment?

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.

Author:  DixiumOS [ Wed Jan 11, 2017 1:29 pm ]
Post subject:  Re: What's your OSDev AWWWW YEAH! moment?

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

Author:  Kevin [ Thu Jan 12, 2017 3:25 am ]
Post subject:  Re: What's your OSDev AWWWW YEAH! moment?

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).

Author:  DixiumOS [ Thu Jan 12, 2017 4:39 am ]
Post subject:  Re: What's your OSDev AWWWW YEAH! moment?

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.

Author:  SpyderTL [ Sun Jul 02, 2017 1:18 am ]
Post subject:  Re: What's your OSDev AWWWW YEAH! moment?

AWWWW YEAH!

Software triangle rendering with vertex color and interpolation... Done!

Attachment:
Triangle.jpg
Triangle.jpg [ 50.15 KiB | Viewed 6559 times ]


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...

Page 12 of 12 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/