Forum Stats

  • 3,872,062 Users
  • 2,266,375 Discussions
  • 7,911,043 Comments

Discussions

ORA-06520/ORA-06522 Error loading library/only ET_DYN and ET_EXEC

716107
716107 Member Posts: 84
edited May 25, 2011 6:38PM in SQL & PL/SQL
Hi Everyone,

I'm trying to setup a trigger to run a shell script on my oracle server and I'm receiving the following errors:

ORA-06520: PL/SQL: Error loading external library
ORA-06522: /opt/oracle/vbl/shell.so: only ET_DYN and ET_EXEC can be loaded

I've tried googling ET_DYN and ET_EXEC but I can't find anything useful that makes sense.

My c code: (shell.c)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void sh(char *);

void sh( char *cmd ) {
int num;
num = system(cmd);
}

Was compiled into .o and .so files.

Google says to check 'nm' but I don't really know what I'm looking for:
nm -g shell.so
0000000000000000 T sh
U system

I've been using this as a roughish guide:
http://www.hoekstra.co.uk/index.php/software-mainmenu-36/oracle-mainmenu-54/13-how-to-build-and-install-oracle-external-procedures.html?showall=1

I'm very confused about where to go from here... advice greatly appreciated!

Thanks :-)
Tagged:

Answers

  • 716107
    716107 Member Posts: 84
    edited May 25, 2011 6:38PM
    The following command:
    ld -shared -o shell.so shell.o

    produces:
    ld: shell.o: relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
    shell.o: could not read symbols: Bad value


    If I attempt to recompile with '-fPIC' I get:
    /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../lib64/crt1.o: In function `_start':
    init.c:(.text+0x20): undefined reference to `main'
    collect2: ld returned 1 exit status

    In the end the following worked:
    gcc -fPIC -DSHARED_OBJECT -c shell.c
    ld -shared -o shell.so shell.o
    file shell.so
    shell.so: ELF 64-bit LSB shared object, AMD x86-64, version 1 (SYSV), not stripped

    Edited by: user11150264 on 25-May-2011 15:38
This discussion has been closed.