exports VS export

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

exports VS export

Alexander Shishkin
what is the difference between "export" proedure/function modifier and
listing this routine in "exports" section?
On win32 with fpc 2.4.3 i've got a crash on program start then using
export modifier in statically linked dll.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: exports VS export

Jonas Maebe-2

On 18 Jan 2011, at 13:27, Alex Shishkin wrote:

> what is the difference between "export" proedure/function modifier  
> and listing this routine in "exports" section?

In theory, they should mean the same.

In practice, FPC currently only actually exports routines that are in  
the "exports" section of a library, or that are marked as export *and*  
that have been (re)compiled during the current compilation run (i.e.,  
that were not compiled previous compilation and simply loaded from  
a .ppu file). See http://bugs.freepascal.org/view.php?id=16070


Jonas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: exports VS export

Alexander Shishkin
18.01.2011 15:34, Jonas Maebe пишет:

>
> On 18 Jan 2011, at 13:27, Alex Shishkin wrote:
>
>> what is the difference between "export" proedure/function modifier
>> and listing this routine in "exports" section?
>
> In theory, they should mean the same.
>
> In practice, FPC currently only actually exports routines that are in
> the "exports" section of a library, or that are marked as export *and*
> that have been (re)compiled during the current compilation run (i.e.,
> that were not compiled previous compilation and simply loaded from a
> .ppu file). See http://bugs.freepascal.org/view.php?id=16070
>
>
> Jonas
>
Following code crashes if disable define use_export_section.

library lib;

{$mode objfpc}{$H+}

uses
Classes
{ you can add units after this };

{$R *.res}

{$define use_export_section}

procedure PrintHello; {$ifndef use_export_section} export; {$endif}
begin
WriteLn('Hello world');
end;

{$ifdef use_export_section}

exports PrintHello;

{$endif}

begin
end.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: exports VS export

Jonas Maebe-2

On 18 Jan 2011, at 13:47, Alex Shishkin wrote:

> Following code crashes if disable define use_export_section.

What do you mean by "crashes"? A segmentation fault? If so, where exactly does it crash? And how do you import that routine in the program and call it? Currently, the "export" modifier apparently does not add an alias for the unmangled name, so I'm not sure how you are even getting things linked successfully.


Jonas_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: exports VS export

Alexander Shishkin
18.01.2011 22:28, Jonas Maebe пишет:
> What do you mean by "crashes"? A segmentation fault? If so, where exactly does it crash? And how do you import that routine in the program and call it? Currently, the "export" modifier apparently does not add an alias for the unmangled name, so I'm not sure how you are even getting things linked successfully.
>
Attempt to run with static linking crashes debugger. Dynamic linking
simply failed. So I ask what does modifier "export" actually do?
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: exports VS export

Jonas Maebe-2

On 18 Jan 2011, at 20:46, Alex Shishkin wrote:

> 18.01.2011 22:28, Jonas Maebe пишет:
>> What do you mean by "crashes"? A segmentation fault? If so, where exactly does it crash? And how do you import that routine in the program and call it? Currently, the "export" modifier apparently does not add an alias for the unmangled name, so I'm not sure how you are even getting things linked successfully.
>>
> Attempt to run with static linking crashes debugger.

You posted the source to a library. It is not possible to run a library. So again: what is the program that you wrote that imports that routine and how did you import that routine in that program?

Additionally, afaik FPC does not currently support creating statically linkable libraries. So how did you statically link a compilation unit that starts with the "library" keyword into a program?

> Dynamic linking simply failed

What is the error that you got?

> So I ask what does modifier "export" actually do?

a) it makes the routine's symbol public, so that it can be referenced from other object files
b) for the OS/2 and EMX targets, it also adds the routine to the "deffile" (I don't know the details about that)


Jonas_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: exports VS export

Alexander Shishkin
18.01.2011 23:08, Jonas Maebe пишет:
> On 18 Jan 2011, at 20:46, Alex Shishkin wrote:
>
>> 18.01.2011 22:28, Jonas Maebe пишет:
>>> What do you mean by "crashes"? A segmentation fault? If so, where exactly does it crash? And how do you import that routine in the program and call it? Currently, the "export" modifier apparently does not add an alias for the unmangled name, so I'm not sure how you are even getting things linked successfully.
>>>
>> Attempt to run with static linking crashes debugger.
> You posted the source to a library. It is not possible to run a library. So again: what is the program that you wrote that imports that routine and how did you import that routine in that program?
>
> Additionally, afaik FPC does not currently support creating statically linkable libraries. So how did you statically link a compilation unit that starts with the "library" keyword into a program?
I meant using "external 'lib.dll' "
>> Dynamic linking simply failed
> What is the error that you got?
"procedure could not be found"
>> So I ask what does modifier "export" actually do?
> a) it makes the routine's symbol public, so that it can be referenced from other object files
> b) for the OS/2 and EMX targets, it also adds the routine to the "deffile" (I don't know the details about that)
>
clear thanks.

Alex.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal