POV-Ray : Newsgroups : povray.off-topic : Linking : Re: Linking Server Time
3 Jul 2024 00:00:33 EDT (-0400)
  Re: Linking  
From: clipka
Date: 31 May 2016 13:50:34
Message: <574dceea$1@news.povray.org>
Am 29.05.2016 um 09:26 schrieb Orchid Win7 v1:

>> The linker will later use that table to update those memory locations.
> 
> Oh, I see. So, what, the jump op-code says to jump to address zero, and
> the object metadata tells the linker which bytes to change?

Yup.

>> You /could/ look it up... you know, they have this fancy new thing
>> called the Internet, and search engines and things ;)
> 
> Don't you start. I've already spent a day looking at the output of nm,
> objdump and readelf. :-P The manpages tell you what all the switches do,
> but I still have no idea what .text is supposed to mean.

I haven't ever looked at any of those, but when I hear "text" in the
context of linking, I think of the "text segment", which is where all
the instructions will be stored (aka "code segment" as Intel would call it).

>>> For that matter, is it possible to store *data* in an object file? (As
>>> opposed to executable code.)
>>
>> Absolutely. See the `source/base/font/*.cpp` files in the POV-Ray source
>> code for examples.
> 
> Hmm. Interesting.
> 
>   extern const unsigned char font_timrom[36936]={...
> 
> I didn't think you could make an array const. (Wouldn't that just mean
> the array pointer itself is constant? Not the array it points to.) And I
> thought extern means "this is declared somewhere else"?

The "const unsigned char FOO[...]={...}" means that FOO is an array of
constant unsigned chars.

Without the "const", it would mean that the array, although initialized
at startup, could be tampered with later.

As for the "extern" that keyword does /not/ denote that the thing is
defined(!) "somewhere else", but that the thing "has external linkage",
i.e. is shared by multiple translation units (= .c or .cpp files).

Some library authors seem to go to great lengths to declare stuff as
"extern" when their header files are included from code that uses the
library, but leave out that "extern" when included from the library
itself; I currently don't know why they do that -- according to the C
and C++ standards this can only work because most stuff is implicitly
"extern" anyway unless explicitly declared "static".

It so happens that "const" stuff is one of the few things implicitly
"static" unless explicitly declared "extern".


> [Also... Heh, do you know, when you said it, I was thinking I'd be able
> to browse the source online somewhere. Silly me...]

Silly you indeed for not figuring out that you can indeed browse the
source code on GitHub ;)

https://github.com/POV-Ray/povray/tree/master/source/base/font


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.