Re: [fpc-pascal] Re: Object Files

2011-07-18 Thread Flávio Etrusco
On Mon, Jul 18, 2011 at 2:07 PM, leledumbo  wrote:
>> Are object files platform dependent?
>
> No

>From the rest of your post I guess you mean "yes, they are dependent"?


>
>> Something tells me they ARE platform independent since they have to be
>> linked in.
>
> Pardon me? That seems unrelated. Object files are basically executables with
> external symbols unresolved and no starting point, do you think executables
> platform independent?
>

He's asking exactly this. If there was no difference in calling
conventions and every access to the OS was through the RTL it could be
cross-platform in this sense (since he's changing the OS but not the
processor/architecture).

-Flávio
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Re: Object Files

2011-07-18 Thread Sven Barth

On 18.07.2011 19:07, leledumbo wrote:

Are object files platform dependent?


No

Depending on the context the author thought in this could have been 
answered with "yes, mostly" as well:
You can't use object files from x86 on ARM or from Windows on Linux (in 
the sense of using the object file from the other platform and trying to 
link and run it on this platform (without emulation)). The last 
restriction basically because the output format is different (PE/COFF vs 
ELF). The object files between e.g. Win32 and WinCE on x86 are 
compatible and the different ELF based systems might be compatible if 
they run on the same platform (don't know that for sure though).
But even if you'd have compatible object files you'd have the problem 
that e.g. the Linux one might contain different assumptions about 
structures and call different functions than the FreeBSD one (thus 
problems when linking or during runtime).


Regards,
Sven
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Re: Pascal and static executable

2011-07-18 Thread leledumbo
> Why does Pascal compiler generate static linked executable while C/++
compiler will generate dynamic executable ?

It's really compiler dependent. There are Pascal compilers that generate
dynamically linked executables by default and there are C/C++ compilers that
generate static executables by default.

> What are the benefits in this approach and what are the bad things with it
> ?

As stated by Jonas + from me: one bad thing about static linking, you can't
have modular application at binary level, i.e. a couple of executables that
share common codes residing in dynamically linked libraries. one good thing,
static linking allows the linker to do dead code elimination (smartlinking
in FPC term), so your executables contain only codes + datas that it really
uses, thus reducing the size.

--
View this message in context: 
http://free-pascal-general.1045716.n5.nabble.com/Pascal-and-static-executable-tp4598551p4600397.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Re: Object Files

2011-07-18 Thread leledumbo
> Are object files platform dependent?

No

> Can you use object files created on Windows with a project compiled on
> Linux?

Only if they're cross compiled to target Linux

> Something tells me they ARE platform independent since they have to be
> linked in. 

Pardon me? That seems unrelated. Object files are basically executables with
external symbols unresolved and no starting point, do you think executables
platform independent?

--
View this message in context: 
http://free-pascal-general.1045716.n5.nabble.com/Object-Files-tp4599906p4600367.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Object Files

2011-07-18 Thread Lee Jenkins


Are object files platform dependent?  Can you use object files created on 
Windows with a project compiled on Linux?  Never used them before.


Something tells me they ARE platform independent since they have to be linked 
in.

--
Warm Regards,

Lee

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Pascal and static executable

2011-07-18 Thread Jonas Maebe

On 18 Jul 2011, at 10:03, ik wrote:

> Let's say that I write the following code:
> 
> program say_hello;
> 
> begin
>  writeln('Hello');
> end.
> 
> program say_helloworld;
> 
> begin
>  writeln('Hello World');
> end.
> 
> They both have the same size and the same memory footprint.
> So what exactly is going on ?

Alignment/rounding of section sizes.

> Why does Pascal compiler generate static
> linked executable while C/++ compiler will generate dynamic executable ?
> 
> What are the benefits in this approach and what are the bad things with it ?

With static linking, you can copy the program to other systems and it will 
normally just work. With dynamic linking, the target systems needs a version of 
the same dynamic library (or a compatible version for the program to run. The 
advantage of dynamic linking is that shared libraries can be loaded in memory 
just once, and then the same copy of the library can be used by all programs 
that link to it (with copy-on-write for writable sections of the data, so that 
programs won't influence each other when writing).

FPC's rtl interface is not very stable, so using a shared library approach 
would probably cause lots of compatibility problems (or require the 
installation of many different version of the FPC rtl shared library, with most 
programs using a different version). The interface of libstdc++ changes less 
often.


Jonas___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Pascal and static executable

2011-07-18 Thread ik
Hello List,

I'm writing an article about modern (Object) Pascal, but there is one
subject that I do not fully understand (for the article that is :)) and I
wish to be prepared for it.

Let's say that I write the following code:

program say_hello;

begin
  writeln('Hello');
end.


This code is not linked to any shared library and therefor consider to be
static linked. However if I write the following code:

program say_helloworld;

begin
  writeln('Hello World');
end.


They both have the same size and the same memory footprint.
So what exactly is going on ? Why does Pascal compiler generate static
linked executable while C/++ compiler will generate dynamic executable ?

What are the benefits in this approach and what are the bad things with it ?

Thanks,

Ido
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal