RE: AIX support

From: Srirama Kucherlapati <sriram(dot)rk(at)in(dot)ibm(dot)com>
To: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, Heikki Linnakangas <hlinnaka(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Eisentraut <peter(at)eisentraut(dot)org>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>, Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, Noah Misch <noah(at)leadboat(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, Andres Freund <andres(at)anarazel(dot)de>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, "tvk1271(at)gmail(dot)com" <tvk1271(at)gmail(dot)com>, "postgres-ibm-aix(at)wwpdl(dot)vnet(dot)ibm(dot)com" <postgres-ibm-aix(at)wwpdl(dot)vnet(dot)ibm(dot)com>, Bruce Momjian <bruce(at)momjian(dot)us>
Subject: RE: AIX support
Date: 2024-09-17 16:29:01
Message-ID: CY8PR15MB5602561E7BF438A1B6C5371BDB612@CY8PR15MB5602.namprd15.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> Do you still need mkldexport.sh? Surely there's a better way to do that
> in year 2024. Some quick googling says there's a '-bexpall' option to
> 'ld', which kind of sounds like what we want. Will that work? How do
> other programs do this?

We have noticed couple of caveats with these flags -bexpall/-bexpfull in other
opensource tools on AIX. This option would export too many symbols causing
problems because a shared library may re-export symbols from another library
causing confused dependencies, duplicate symbols.

We have similar discussion wrt to these flag in Cmake

https://gitlab.kitware.com/cmake/cmake/-/issues/19163

Also, I tried some sample program to verify the same as below

>> cat foo.c

#include <stdio.h>

#include <string.h>

int func1()

{

char str1[] = "Hello ", str2[] = "world! ";

strcat(str1,str2);

puts(str1);

return 0;

}

>> gcc -c foo.c -o foo.o

>> gcc -shared -Wl,-bexpall -o foo.so foo.o

>> dump -Tov foo.so

foo.so:

***Object Module Header***

# Sections Symbol Ptr # Symbols Opt Hdr Len Flags

4 0x00000d88 120 72 0x3002

Flags=( EXEC DYNLOAD SHROBJ DEP_SYSTEM )

Timestamp = "Sep 17 10:17:35 2024"

Magic = 0x1df (32-bit XCOFF)

***Optional Header***

Tsize Dsize Bsize Tstart Dstart

0x00000548 0x0000010c 0x00000004 0x10000128 0x20000670

SNloader SNentry SNtext SNtoc SNdata

0x0004 0x0000 0x0001 0x0002 0x0002

TXTalign DATAalign TOC vstamp entry

0x0005 0x0004 0x20000750 0x0001 0xffffffff

maxSTACK maxDATA SNbss magic modtype

0x00000000 0x00000000 0x0003 0x010b RE

***Loader Section***

***Loader Symbol Table Information***

[Index] Value Scn IMEX Sclass Type IMPid Name

[0] 0x2000068c .data RW SECdef [noIMid] __rtinit

[1] 0x00000000 undef IMP DS EXTref libgcc_s.a(shr.o) __cxa_finalize

[2] 0x00000000 undef IMP DS EXTref libgcc_s.a(shr.o) _GLOBAL__AIXI_shr_o

[3] 0x00000000 undef IMP DS EXTref libgcc_s.a(shr.o) _GLOBAL__AIXD_shr_o

[4] 0x00000000 undef IMP DS EXTref libc.a(shr.o) __strtollmax

[5] 0x00000000 undef IMP DS EXTref libc.a(shr.o) puts

[6] 0x200006f4 .data EXP DS Ldef [noIMid] __init_aix_libgcc_cxa_atexit

[7] 0x20000724 .data EXP DS Ldef [noIMid] _GLOBAL__AIXI_foo_so

[8] 0x20000730 .data EXP DS Ldef [noIMid] _GLOBAL__AIXD_foo_so

>> [9] 0x2000073c .data EXP DS SECdef [noIMid] strcat

[10] 0x20000744 .data EXP DS Ldef [noIMid] func1

The code makes use of strcat from libc but re-exports the symbol (because of -bexpall).

As of now due to the limitation with these flags (-bexpall / -bexpfull ? ), the

solution here is to continue to extract the symbols from the object files and

use that export file as part of building the shared library. (Continue to use

the mkldexport.sh script to generate the export symbols).

Thanks,
Sriram.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2024-09-17 17:54:05 Re: Conflict detection for update_deleted in logical replication
Previous Message Peter Geoghegan 2024-09-17 15:49:11 Re: Adding skip scan (including MDAM style range skip scan) to nbtree