You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Stas Bekman <st...@stason.org> on 2003/03/21 05:19:06 UTC

AIX: ld -bI:httpd.exp vs. ld -lhttpd

In mod_perl 2.0 on AIX we have to import symbols from ap_ and apr_ namespaces
when linking the shared object (the other approach is to use -berok which
works as symbols get resolved at load time, but this is too error-prone).

The following two ways to import apr_ symbols seem to have the same effect
(let's say that there is only apr, and no aprutil for simplicity):

ld -bM:SRE -brtl -bnoentry -bI:/path/to/apr.exp a.o b.o -o foo.o

or

ld -bM:SRE -brtl -bnoentry -lapr a.o b.o -o foo.o

it looks like the loader figures out the imported symbols either from apr.exp
or from apr.so. It seems that the latter way is preffered since the exp file
could be wrong, whereas the shared object is always correct.

Am I correct so far? (I'm still quite new to aix ld's mechanics and yes, I've
read the ld manpage too many times.)

If so how do I tell ld to use the symbols from httpd, which is an executable
app and not a shared library. I'd like to avoid referencing exp files at all
for importing symbols, and let the loader figure out what symbols to import
from the object.

Thank you.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Re: AIX: ld -bI:httpd.exp vs. ld -lhttpd

Posted by Stas Bekman <st...@stason.org>.
Jeff Trawick wrote:
> Stas Bekman wrote:
> 
>> Yesterday, I've patched the mod_perl 2.0 build code to build on aix 
>> (tested on powerpc/aix/5.1). The interesting thing that I haven't used 
>> .exp's at all (neither -lapr/-laprutil/etc). I've used -berok and 
>> -brtl and let everything to be resolved at the startup time. This 
>> seems to work just fine, since by the time mod_perl boots, 
>> httpd/apr/aprutil are all loaded in memory.
>>
>> Do you think this will work on other aix versions/platforms?
> 
> I think so (at least 4.3 and above)

so far it seems to work with 4.3 and 5.1

> you do have run-time linking enabled, right?  using the APR ldflags 
> (like apxs does) will get that turned on

Yup, -brtl

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Re: AIX: ld -bI:httpd.exp vs. ld -lhttpd

Posted by Jeff Trawick <tr...@attglobal.net>.
Stas Bekman wrote:
> Yesterday, I've patched the mod_perl 2.0 build code to build on aix 
> (tested on powerpc/aix/5.1). The interesting thing that I haven't used 
> .exp's at all (neither -lapr/-laprutil/etc). I've used -berok and -brtl 
> and let everything to be resolved at the startup time. This seems to 
> work just fine, since by the time mod_perl boots, httpd/apr/aprutil are 
> all loaded in memory.
> 
> Do you think this will work on other aix versions/platforms?

I think so (at least 4.3 and above)

you do have run-time linking enabled, right?  using the APR ldflags 
(like apxs does) will get that turned on


Re: AIX: ld -bI:httpd.exp vs. ld -lhttpd

Posted by Stas Bekman <st...@stason.org>.
Jeff Trawick wrote:
> Stas Bekman wrote:
> 
>> Jeff Trawick wrote:
>>
>>> The shared object has symbols that aren't intended for use by 
>>> applications, whereas the .exp file doesn't.  Personally, I think it 
>>> is a good thing that we have a tight control over our API, so I think 
>>> in terms of getting httpd.exp fixed instead of forgetting about that 
>>> mechanism altogether.
>>
>>
>>
>> So, you say that it's a better practice to use the exp file than the 
>> shared object. Especially since I still not sure what the shared 
>> object is in case of httpd (in contrast to apr/apr-util which are libs).
> 
> 
> yes, in my opinion it is better practice to use the exp file

Thanks Jeff!

>>> mod_perl has been caught before on AIX calling functions which 
>>> weren't intended to be part of the API because of the use of 
>>> httpd.exp.  Is that useful to anybody?
>>
>>
>>
>> Sorry, I'm not following you here. You just said above that using 
>> httpd.exp is the safest since it only provides symbols which are 
>> exported.
> 
> 
> this was an attempt at anecdotal support for what I mentioned earlier...
> 
> more clearly:
> 
> a couple of years ago mod_perl wouldn't build on AIX because it called 
> an httpd function which wasn't listed in httpd.exp...  it wasn't listed 
> in httpd.exp because it wasn't an intended part of the API...

That's a similar trouble I've had with apr_generate_random_bytes, but for a 
different reason (not using APR_HAS_RANDOM).

Yesterday, I've patched the mod_perl 2.0 build code to build on aix (tested on 
powerpc/aix/5.1). The interesting thing that I haven't used .exp's at all 
(neither -lapr/-laprutil/etc). I've used -berok and -brtl and let everything 
to be resolved at the startup time. This seems to work just fine, since by the 
time mod_perl boots, httpd/apr/aprutil are all loaded in memory.

Do you think this will work on other aix versions/platforms?

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Re: AIX: ld -bI:httpd.exp vs. ld -lhttpd

Posted by Jeff Trawick <tr...@attglobal.net>.
Stas Bekman wrote:
> Jeff Trawick wrote:
> 
>> The shared object has symbols that aren't intended for use by 
>> applications, whereas the .exp file doesn't.  Personally, I think it 
>> is a good thing that we have a tight control over our API, so I think 
>> in terms of getting httpd.exp fixed instead of forgetting about that 
>> mechanism altogether.
> 
> 
> So, you say that it's a better practice to use the exp file than the 
> shared object. Especially since I still not sure what the shared object 
> is in case of httpd (in contrast to apr/apr-util which are libs).

yes, in my opinion it is better practice to use the exp file

>> mod_perl has been caught before on AIX calling functions which weren't 
>> intended to be part of the API because of the use of httpd.exp.  Is 
>> that useful to anybody?
> 
> 
> Sorry, I'm not following you here. You just said above that using 
> httpd.exp is the safest since it only provides symbols which are exported.

this was an attempt at anecdotal support for what I mentioned earlier...

more clearly:

a couple of years ago mod_perl wouldn't build on AIX because it called 
an httpd function which wasn't listed in httpd.exp...  it wasn't listed 
in httpd.exp because it wasn't an intended part of the API...


Re: AIX: ld -bI:httpd.exp vs. ld -lhttpd

Posted by Stas Bekman <st...@stason.org>.
Jeff Trawick wrote:
> Stas Bekman wrote:
> 
>> In mod_perl 2.0 on AIX we have to import symbols from ap_ and apr_ 
>> namespaces
>> when linking the shared object (the other approach is to use -berok which
>> works as symbols get resolved at load time, but this is too error-prone).
>>
>> The following two ways to import apr_ symbols seem to have the same 
>> effect
>> (let's say that there is only apr, and no aprutil for simplicity):
>>
>> ld -bM:SRE -brtl -bnoentry -bI:/path/to/apr.exp a.o b.o -o foo.o
>>
>> or
>>
>> ld -bM:SRE -brtl -bnoentry -lapr a.o b.o -o foo.o
>>
>> it looks like the loader figures out the imported symbols either from 
>> apr.exp
>> or from apr.so. It seems that the latter way is preffered since the 
>> exp file
>> could be wrong, whereas the shared object is always correct.
> 
> 
> The shared object has symbols that aren't intended for use by 
> applications, whereas the .exp file doesn't.  Personally, I think it is 
> a good thing that we have a tight control over our API, so I think in 
> terms of getting httpd.exp fixed instead of forgetting about that 
> mechanism altogether.

So, you say that it's a better practice to use the exp file than the shared 
object. Especially since I still not sure what the shared object is in case of 
httpd (in contrast to apr/apr-util which are libs).

> mod_perl has been caught before on AIX calling functions which weren't 
> intended to be part of the API because of the use of httpd.exp.  Is that 
> useful to anybody?

Sorry, I'm not following you here. You just said above that using httpd.exp is 
the safest since it only provides symbols which are exported.

> Also, if httpd.exp is broken, it is because exports.c is broken, so 
> there may be additional reasons to get the parse problem or symbol 
> declaration problem resolved.
> 
> -- 
> 
> By the way, what is the symbol that should be in httpd.exp but isn't?

None that I know of in the current version. At least I haven't encountered any 
with the mod_perl test suite on aix.

I think there were problems in older versions, can't recall now and since 
people try to build mod_perl with older httpds. I was looking for a 
error-proof way to build against any httpd version, assuming that using the 
executable is safer than .exp for importing symbols, because the executable 
(shared lib) is always right.


__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Re: AIX: ld -bI:httpd.exp vs. ld -lhttpd

Posted by Jeff Trawick <tr...@attglobal.net>.
Stas Bekman wrote:
> In mod_perl 2.0 on AIX we have to import symbols from ap_ and apr_ 
> namespaces
> when linking the shared object (the other approach is to use -berok which
> works as symbols get resolved at load time, but this is too error-prone).
> 
> The following two ways to import apr_ symbols seem to have the same effect
> (let's say that there is only apr, and no aprutil for simplicity):
> 
> ld -bM:SRE -brtl -bnoentry -bI:/path/to/apr.exp a.o b.o -o foo.o
> 
> or
> 
> ld -bM:SRE -brtl -bnoentry -lapr a.o b.o -o foo.o
> 
> it looks like the loader figures out the imported symbols either from 
> apr.exp
> or from apr.so. It seems that the latter way is preffered since the exp 
> file
> could be wrong, whereas the shared object is always correct.

The shared object has symbols that aren't intended for use by 
applications, whereas the .exp file doesn't.  Personally, I think it is 
a good thing that we have a tight control over our API, so I think in 
terms of getting httpd.exp fixed instead of forgetting about that 
mechanism altogether.

mod_perl has been caught before on AIX calling functions which weren't 
intended to be part of the API because of the use of httpd.exp.  Is that 
useful to anybody?

Also, if httpd.exp is broken, it is because exports.c is broken, so 
there may be additional reasons to get the parse problem or symbol 
declaration problem resolved.

--

By the way, what is the symbol that should be in httpd.exp but isn't?