Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2010-03

Smartlinking public functions

5 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

dmitry boyarintsev

Hello Developers

The system expects an application to implement (export) some functions that are to be linked statically.

I'm using [public] modifier:
function someFunc: Integer cdecl; [public]; alias: '_someFunc';

The linker catches up the function and statically links it with the system library.

The problem comes with using smartlinking -XX switch. Since someFunc is not used by my code, the compiler considers it useless and throws away.
The linker fails to find the symbol name and so a system routing, that uses the exported functions, simply fails.

I can insert the usage code, like

initialization
  if @someFunc = nil then Halt(255);

This would prevent the smartlinking, but is there more beautiful way to prevent a function from being smartlinked?

thanks,
dmitry

Reply by email

Jonas Maebe
to dmitry boyarintsev
dmitry boyarintsev wrote
This would prevent the smartlinking, but is there more beautiful way to prevent a function from being smartlinked?

No. And even if we would add a special modifier for that, I don't know how it could be easily implemented for non-Mac OS X platforms (although I realise that you probably need this for Mac OS X, a generic modifier would have to be supportable everywhere).

Jonas

Reply by email

dmitry boyarintsev
to Jonas Maebe
Jonas Maebe wrote
No. And even if we would add a special modifier for that, I don't know how it could be easily implemented for non-Mac OS X platforms (although I realise that you probably need this for Mac OS X, a generic modifier would have to be supportable everywhere).

Ok, so using dummy code is fine by now?

btw, is weakexternal modifier OSX specific? and not supported for other platforms?

thanks,
dmitry

Reply by email

Jonas Maebe
to dmitry boyarintsev
dmitry boyarintsev wrote
On Sat, Mar 6, 2010 at 9:14 PM, Jonas Maebe wrote: > No. And even if we would add a special modifier for that, I don't know how it could be easily implemented for non-Mac OS X platforms (although I realise that you probably need this for Mac OS X, a generic modifier would have to be supportable everywhere). Ok, so using dummy code is fine by now?

Yes.

btw, is weakexternal modifier OSX specific? and not supported for other platforms?

It also works on Solaris, and on Linux if you use the external assembler. It can also be implemented for other platforms (and for the internal assembler), but nobody has done this yet.

Jonas

Reply by email