Bug 1649 - inappropriate linker options for AIX 5L
Summary: inappropriate linker options for AIX 5L
Status: RESOLVED FIXED
Alias: None
Product: Samba 3.0
Classification: Unclassified
Component: Build environment (show other bugs)
Version: 3.0.6
Hardware: PPC AIX
: P3 normal
Target Milestone: none
Assignee: William Jojo
QA Contact: Samba QA Contact
URL:
Keywords:
: 3627 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-08-23 05:24 UTC by Doug VanLeuven
Modified: 2006-04-10 06:27 UTC (History)
1 user (show)

See Also:


Attachments
AIX shared vfs object patch (572 bytes, patch)
2006-03-09 15:20 UTC, William Jojo
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Doug VanLeuven 2004-08-23 05:24:23 UTC
Hi,
samba svn 1665. AIX 5.1.0.50. This is a bug and a fix. I don't know any other
way.  Years ago, I used to correspond on samba-technical, but no one appears to
be interested anymore.  I guess you're a corporation now.

Please fix this.  It would be so nice for samba to configure and run out of the
box on AIX.  I haven't got to WINBIND pluggable authentication module yet, so
those options aren't in this patch, but I'd bet the same will apply.

1. The security model was enhanced in AIX 5.2.  The version method does not
exist in 5.1.  This only affects one definition in winbind_nss_aix.c, but
requires additional aix version tests.  I left it easy to add an additional test
for 5.3 cause I think it will be different again.

2. The linker was redesigned.  Supposedly in AIX 4.3.3, but I don't have that
available to test.  The -G option was introduced to assist linking shared
modules.  Using the old options will panic samba and winbind when loading
dynamic modules.  Probably the offending option is the default behavior
-bnosymbolic- (yes that's a trailing hyphen) which -G changes to -bnosymbolic. 
But why not just use the new system?

3.  -nostartfiles when using gcc to invoke the linker on shared modules to avoid
duplicate symbols.

This patch addresses those issues.  The line numbers are off by a couple because
 of a test I do to eliminate strndup & strnlen further up in configure.in.

--- configure.in.orig   2004-08-19 18:17:50.000000000 -0700
+++ configure.in        2004-08-22 07:51:03.000000000 -0700
@@ -1197,12 +1203,25 @@
                      ;;
              *aix*) AC_DEFINE(AIX,1,[Whether the host os is aix])
                      BLDSHARED="true"
-                       LDSHFLAGS="-Wl,-bexpall,-bM:SRE,-bnoentry,-berok"
+                       case "$host_os" in
+                       *aix4*|*aix3*)
+                               LDSHFLAGS="-Wl,-bexpall,-bM:SRE,-bnoentry,-berok"
+                               ;;
+                       *)      LDSHFLAGS="-Wl,-G,-bexpall,-bnoentry"
+                               case `uname -r` in
+                                  0|1) ;;
+                                  *)   AC_DEFINE(AIX52,1,[Whether the host os
is aix 5.2 or later])
+                                       ;;
+                               esac
+                               ;;
+                       esac
                      DYNEXP="-Wl,-brtl,-bexpall"
                      PICFLAGS="-O2"
                      if test "${GCC}" != "yes"; then
                              ## for funky AIX compiler using strncpy()
                              CFLAGS="$CFLAGS -D_LINUX_SOURCE_COMPAT -qmaxmem=32000"
+                       else
+                               LDSHFLAGS="-nostartfiles $LDSHFLAGS"
                      fi

                      AC_DEFINE(STAT_ST_BLOCKSIZE,DEV_BSIZE,[The size of a block])

--- nsswitch/winbind_nss_aix.c.orig     2004-08-22 07:51:59.000000000 -0700
+++ nsswitch/winbind_nss_aix.c  2004-08-22 07:39:29.000000000 -0700
@@ -977,7 +977,9 @@
{
      ZERO_STRUCTP(methods);

+#ifdef AIX52
      methods->method_version = SECMETHOD_VERSION_520;
+#endif

      methods->method_getgrgid           = wb_aix_getgrgid;
      methods->method_getgrnam           = wb_aix_getgrnam;
Comment 1 Gerald (Jerry) Carter (dead mail address) 2004-08-23 06:28:40 UTC
(In reply to comment #0)

> samba svn 1665. AIX 5.1.0.50. This is a bug and a fix. I 
> don't know any other way.  Years ago, I used to correspond 
> on samba-technical, but no one appears to be interested anymore.  
> I guess you're a corporation now.

Ouch.  You first posted on 8/21 that I can tell
Subject : "broken strndup on AIX 5.1".  Pretty quick to 
complain that no one is interested anymore.  I see someone 
replied this morning.

Anyways, it's better to track bugs here so that they don't 
get lost.  We'll get this straightened out for 3.0.7.  Thanks 
for the report and the patch.
Comment 2 Doug VanLeuven 2004-08-23 13:46:09 UTC
(In reply to comment #1)
> (In reply to comment #0)
> 
> > samba svn 1665. AIX 5.1.0.50. This is a bug and a fix. I 
> > don't know any other way.  Years ago, I used to correspond 
> > on samba-technical, but no one appears to be interested anymore.  
> > I guess you're a corporation now.
> 
> Ouch.  You first posted on 8/21 that I can tell
> Subject : "broken strndup on AIX 5.1".  Pretty quick to 
> complain that no one is interested anymore.  I see someone 
> replied this morning.

Thanks for the attention.
I was actually bummed because Simo Sorce seemed to be more interested in
incorrectly quoting me and making a joke out of it.  I apologize for letting my
emotions get ahead of my professionalism.
Comment 3 Doug VanLeuven 2005-02-24 21:01:48 UTC
Item one (1) has been addressed.

Item two (2)
If you're interested, here's a link to the page about the difference between -G
and -brtl as linker options written by one of the AIX kernel developers.

http://www-128.ibm.com/developerworks/eserver/tutorials/linking102/linking102-3-1.html

the entire pdf is here, it's fairly short.
http://www-128.ibm.com/developerworks/eserver/tutorials/linking102/linking102-ltr.pdf
Comment 4 Gerald (Jerry) Carter (dead mail address) 2005-09-29 09:46:20 UTC
doug, could you update this erport for 3.0.20?  Do we still have a problem here?
Comment 5 Doug VanLeuven 2005-10-03 16:37:28 UTC
(In reply to comment #4)
> doug, could you update this erport for 3.0.20?  Do we still have a problem here?

By items in original post:
1. winbind_nss_aix.c was fixed using a different test & technique.
2. I still think shared loadable modules should use the "-G" flag to properly
resolve undefined labels at run time.  See the pdf by the author of the AIX
linker (link in previous post).
3. Not everyone uses the native AIX compiler.  There should be a branch in the
logic to set proper flags for gcc.  Subsequent to this post, I started using
"-D_LINUX_SOURCE_COMPAT" in the gcc compile as well.  "-nostartfiles" instructs
gcc not to include the useless initialization functions in loadable modules.

After 30 years working for this outfit, I got wacked by a hostile takeover of
the dept, so I no longer have access to AIX.  Luck to you.
Comment 6 William Jojo 2006-01-18 06:33:28 UTC
-G Produces a shared object enabled for use with the run-time linker. The -G
flag is equivalent to specifying the erok, rtl, nortllib, nosymbolic, noautoexp,
and M:SRE options with the -b flag. Subsequent options can override these
options.

The -G option seems most appropriate, actually, for dynamic modules. I will test the recycle.so for panics. and try the -G and see how it perfoms. I'll also check the patch, although at first review it looks good. I'm concerned about the check on release with no version prior.


Cheers,

Bill
Comment 7 Doug VanLeuven 2006-01-18 10:36:34 UTC
What this check fixed for me, item 1 in the original post, was solved by other means and is no longer required.
+                               case `uname -r` in
+                                  0|1) ;;
+                                  *)   AC_DEFINE(AIX52,1,[Whether the host os
is aix 5.2 or later])
+                                       ;;
+                               esac
+                               ;;
Comment 8 William Jojo 2006-03-09 15:20:50 UTC
Created attachment 1780 [details]
AIX shared vfs object patch

This patch fixes the PANIC for shared vfs modules. Tested with recycle which panicked everytime before this patch.
Comment 9 Jeremy Allison 2006-03-09 16:00:37 UTC
Applied, thanks Bill.

Jeremy.
Comment 10 William Jojo 2006-04-10 06:27:38 UTC
*** Bug 3627 has been marked as a duplicate of this bug. ***