OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Apr 18, 2024 11:56 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: [SOLVED]Errors in tutorial?
PostPosted: Sun Aug 24, 2014 5:36 pm 
Offline
Member
Member
User avatar

Joined: Mon Jan 06, 2014 4:23 pm
Posts: 62
I completely followed the tutorial on writing a OS with D and assembly like I always do when following a tutorial for the first time. When linking the files start.o and kernel.main.d together using linker.ld just like the tutorial said it gave me the following error.
Code:
kernel.main.o: In function `main':
/home/bashcommando/Desktop/starfruit/beta/kernel.main.d:10: undefined reference to `_d_criticalenter'
/home/bashcommando/Desktop/starfruit/beta/kernel.main.d:10: undefined reference to `_d_criticalexit'
/home/bashcommando/Desktop/starfruit/beta/kernel.main.d:12: undefined reference to `_d_criticalenter'
/home/bashcommando/Desktop/starfruit/beta/kernel.main.d:12: undefined reference to `_d_criticalexit'
/home/bashcommando/Desktop/starfruit/beta/kernel.main.d:13: undefined reference to `_d_criticalenter'
/home/bashcommando/Desktop/starfruit/beta/kernel.main.d:13: undefined reference to `_d_criticalexit'
kernel.main.o: In function `kernel.main._D6kernel4main9__modinitFZv':
/home/bashcommando/Desktop/starfruit/beta/kernel.main.d:14: undefined reference to `_Dmodule_ref'
/home/bashcommando/Desktop/starfruit/beta/kernel.main.d:14: undefined reference to `_Dmodule_ref'

_________________
Building an operating system is like building an airplane, you don't want it to crash.


Last edited by bashcommando on Tue Jan 20, 2015 3:46 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Errors in tutorial?
PostPosted: Sun Aug 24, 2014 6:02 pm 
Offline
Member
Member
User avatar

Joined: Wed Aug 21, 2013 3:53 am
Posts: 449
Location: Asia, Singapore
I think there was a option to enable leading underscores (fleading-underscores maybe), enable that and then compile or do it the better way, fix your symbols.
EDIT: The above might not be the issue. I think the compiler expects d_criticalenter and d_criticalexit to be predefined.

_________________
"In a time of universal deceit - telling the truth is a revolutionary act." -- George Orwell
(R3X Runtime VM)(CHIP8 Interpreter OS)


Top
 Profile  
 
 Post subject: Re: Errors in tutorial?
PostPosted: Mon Aug 25, 2014 9:27 am 
Offline
Member
Member
User avatar

Joined: Mon Jan 06, 2014 4:23 pm
Posts: 62
Bender wrote:
I think there was a option to enable leading underscores (fleading-underscores maybe), enable that and then compile or do it the better way, fix your symbols.
EDIT: The above might not be the issue. I think the compiler expects d_criticalenter and d_criticalexit to be predefined.

I typed exactly what the tutorial said. That also means that there is a error in the tutorial. I just figured I should point it out.

_________________
Building an operating system is like building an airplane, you don't want it to crash.


Top
 Profile  
 
 Post subject: Re: Errors in tutorial?
PostPosted: Mon Aug 25, 2014 11:06 am 
Offline
Member
Member

Joined: Wed Mar 30, 2011 12:31 am
Posts: 676
volatile was removed from the D compiler and silently replaced with calls to the D runtime's criticalenter / criticalexit routines. Had you asked Google, you would have found this email thread. There is no error in the tutorial except that it was written before this change to D and has not been updated since.

_________________
toaruos on github | toaruos.org | gitlab | twitter | bim - a text editor


Top
 Profile  
 
 Post subject: Re: Errors in tutorial?
PostPosted: Mon Aug 25, 2014 1:12 pm 
Offline
Member
Member
User avatar

Joined: Sun Feb 18, 2007 7:28 pm
Posts: 1564
Hello,
Quote:
I typed exactly what the tutorial said. That also means that there is a error in the tutorial
Not necessarily. Minor differences between build environments and host operating system can result in errors independent of the tutorial or what the tutorial expects. In addition, the resulting code can be very different resulting in crashes or compiler assuming something that should not yet be used. This is specifically true in operating system development. Rule of thumb is to never copy and paste as there is no guarantee it will work and know your tool chain very well in order to resolve minor details such as the one you are facing now.

_________________
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}


Top
 Profile  
 
 Post subject: Re: Errors in tutorial?
PostPosted: Mon Aug 25, 2014 5:09 pm 
Offline
Member
Member
User avatar

Joined: Mon Jan 06, 2014 4:23 pm
Posts: 62
neon wrote:
Hello,
Quote:
I typed exactly what the tutorial said. That also means that there is a error in the tutorial
Not necessarily. Minor differences between build environments and host operating system can result in errors independent of the tutorial or what the tutorial expects. In addition, the resulting code can be very different resulting in crashes or compiler assuming something that should not yet be used. This is specifically true in operating system development. Rule of thumb is to never copy and paste as there is no guarantee it will work and know your tool chain very well in order to resolve minor details such as the one you are facing now.

Then again, the e-mail thread. Somebody should update it.

_________________
Building an operating system is like building an airplane, you don't want it to crash.


Top
 Profile  
 
 Post subject: Re: Errors in tutorial?
PostPosted: Mon Aug 25, 2014 7:38 pm 
Offline
Member
Member
User avatar

Joined: Sun Feb 18, 2007 7:28 pm
Posts: 1564
bashcommando wrote:
neon wrote:
Hello,
Quote:
I typed exactly what the tutorial said. That also means that there is a error in the tutorial
Not necessarily. Minor differences between build environments and host operating system can result in errors independent of the tutorial or what the tutorial expects. In addition, the resulting code can be very different resulting in crashes or compiler assuming something that should not yet be used. This is specifically true in operating system development. Rule of thumb is to never copy and paste as there is no guarantee it will work and know your tool chain very well in order to resolve minor details such as the one you are facing now.

Then again, the e-mail thread. Somebody should update it.
It is not possible to accommodate the above. I do not quite think you understand the level of detail involved here; it is important to realize that errors will always occur due the above which is why copying and pasting system code will not work well unless you are also copying the build environment and design structure. It is clear that your build environment is different then what was assumed.

It is also very common to have custom build environments and tool chains cross compiled or targeting a specific operating system. The smallest difference can yield to errors. This does not mean the code nor build environment is wrong - rather just differences in design and architecture make different assumptions and have different requirements.

Again, the rule of thumb : Never copy and paste system code and never assume any tutorial or code you find online that provides system code will work for you without modification unless you have a compatible build environment and design suitable to meet the requirements and assumptions of that code - on the design, architecture, and depending on the code, binary level.

_________________
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}


Top
 Profile  
 
 Post subject: Re: Errors in tutorial?
PostPosted: Tue Aug 26, 2014 12:15 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4594
Location: Chichester, UK
bashcommando wrote:
neon wrote:
Hello,
Quote:
I typed exactly what the tutorial said. That also means that there is a error in the tutorial
Not necessarily. Minor differences between build environments and host operating system can result in errors independent of the tutorial or what the tutorial expects. In addition, the resulting code can be very different resulting in crashes or compiler assuming something that should not yet be used. This is specifically true in operating system development. Rule of thumb is to never copy and paste as there is no guarantee it will work and know your tool chain very well in order to resolve minor details such as the one you are facing now.

Then again, the e-mail thread. Somebody should update it.

So go ahead - update it. You are somebody.

They say that you learn more when things go wrong then when they go right. This is true of life in general and very true of OS development. You need to understand your computer hardware and your toolchain intimately. So now you have learnt more than you would have if copy and pasting had just worked.

This is a wiki. Anyone can update it. If you think there are useful changes to be made to it then share your new-found knowledge by updating it. Personally, I'm not convinced that bare-bones tutorials do more good than harm.


Top
 Profile  
 
 Post subject: Re: Errors in tutorial?
PostPosted: Tue Aug 26, 2014 8:47 am 
Offline
Member
Member

Joined: Wed Oct 30, 2013 1:57 pm
Posts: 306
Location: Germany
iansjack wrote:
This is a wiki. Anyone can update it. If you think there are useful changes to be made to it then share your new-found knowledge by updating it. Personally, I'm not convinced that bare-bones tutorials do more good than harm.
If we hadn't the BareBones/Bran's/jmolloy's tutorials, most beginners would just copy from other operating systems, which isn't good, too.

I think it's good that these tutorials exist, but they're sometimes very far away from being perfect. I don't love tutorials that state that assembly language isn't required, simply because that's not true. If you don't have an idea about how, for example, memory addressing works, you will run into problems sooner or later. Also, we should do more in order to prevent new OSdevers from copy&pasting code (I know, some people say it doesn't help, but I still believe in humanity), e.g. by not showing all the code. If we let them do some very basic methods by themselves (let's say the C memset), we could be better off.

Again, keep in mind that's only my personal opinion.

_________________
managarm


Top
 Profile  
 
 Post subject: Re: Errors in tutorial?
PostPosted: Tue Aug 26, 2014 9:55 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4594
Location: Chichester, UK
I'm still not convinced.

I don't think that the people who copy and paste from bare-bones tutorials would be doing the same from, for example, the Linux source code. Mind they'd learn a lot more (before and after) if they did. I'd rather see another Unix clone than another bootloader that prints "Hello World".


Top
 Profile  
 
 Post subject: Re: Errors in tutorial?
PostPosted: Tue Aug 26, 2014 11:02 am 
Offline
Member
Member

Joined: Wed Oct 30, 2013 1:57 pm
Posts: 306
Location: Germany
iansjack wrote:
I'm still not convinced.

I don't think that the people who copy and paste from bare-bones tutorials would be doing the same from, for example, the Linux source code. Mind they'd learn a lot more (before and after) if they did. I'd rather see another Unix clone than another bootloader that prints "Hello World".
I didn't mean that they will copy from Linux, but from slightly advanced hobby OSes (klange's toaruos, for example) or other not-so-advanced OSes. Sorry for that miscommunication.

_________________
managarm


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 57 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