Operating System - HP-UX
1753774 Members
7057 Online
108799 Solutions
New Discussion юеВ

Re: mod_perl exec format error

 
SOLVED
Go to solution
Michael Simone
Frequent Advisor

mod_perl exec format error

Latest roadblock in my agonizing open source saga...

I got my 11.11 system setup with 64-bit versions of gcc 3.4.2, Perl 5.8.5 (thanks Procura), DBI, DBD-Oracle, and Apache 2.0.51. Everything built nicely, and Apache fired up correctly. (My problem for the last 3 days was that I didn't realize I had a 64-bit kernel--duh!).

Anyway, now I'm trying to install mod_perl 2.0 (1.99.16). The source builds correctly, and I go all the way through make install, and the mod_perl.so file is in my Apache directory. But when I try to fire up Apache with it in the conf, I get:

Cannot load /usr/local/apache/modules/mod_perl.so into server: Exec format error

I went back and redid the build, and made sure I let the make test portion run, and the same error occurs in make test.

What's the deal? Everything's being built with gcc 3.4.2 (Procura's Perl that I installed was built with 3.4.3, but I think that's fine). Isn't exec format error something to do with binary incompatibility? Can't find anything on Google for this. Help please.
6 REPLIES 6
ranganath ramachandra
Esteemed Contributor

Re: mod_perl exec format error

what does "file mod_perl.so" show ? it should be a shared library, else its a bad format to load.

if it is a shared library, its ABI should match with that of your executable (i.e. you cant have one 32-bit and other 64-bit).

if its a shared library of matching ABI, it better not have any thread local storage (TLS) in it (unless you are on IA64?). also none of its dependencies can have TLS. dlopen/shl_load cant load shared libraries that have TLS in them, at least on PA.

for PA32 shared libraries you can see this using "odump -subspace mod_perl.so" - the "$TBSS$" and "$TDATA$" subspaces, if they exist, should be of zero size.

for PA64, use "elfdump -S -h mod_perl.so" - the .tbss and .tdata sections should be of zero length.

if you find that a shared library - either mod_perl.so or one of its dependecies - has TLS in it, you can work around this problem by statically linking it with the executable (include it in the link line) or pre-loading it at run-time using the LD_PRELOAD_ONCE or LD_PRELOAD environment variables.
 
--
ranga
[i work for hpe]

Accept or Kudo

ranganath ramachandra
Esteemed Contributor

Re: mod_perl exec format error

you can use chatr or ldd on mod_perl.so to list its dependencies.

also if you are using SHLIB_PATH for both PA32 and PA64, please try to put all the PA32 paths first and PA64 paths later - the PA64 loader is smarter in ignoring unknown file types.
 
--
ranga
[i work for hpe]

Accept or Kudo

Michael Simone
Frequent Advisor

Re: mod_perl exec format error

Well, this much looks okay:
/usr/local/apache/bin/httpd: ELF-64 executable object file - PA-RISC 2.0 (LP64)

/usr/local/apache/modules/mod_perl.so: ELF-64 shared object file - PA-RISC 2.0 (LP64)

I'm not sure, but I think this looks okay:
Web-01.root# elfdump -S -h mod_perl.so

mod_perl.so:

*** Section Header ***

Index Type Vaddr Offset Size Name

1 DYNM 40000000000001c8 00000000000001c8 000001b0 .dynamic
2 DYNS 4000000000000378 0000000000000378 0000ed78 .dynsym
3 STRT 400000000000f0f0 000000000000f0f0 0000a0b2 .dynstr
4 HASH 40000000000191a8 00000000000191a8 00003b64 .hash
5 RELA 400000000001cd10 000000000001cd10 0001a8b0 .rela.dlt
6 RELA 40000000000375c0 00000000000375c0 00009e40 .rela.data.rel.local
7 RELA 4000000000041400 0000000000041400 00001c80 .rela.data.rel.ro
8 RELA 4000000000043080 0000000000043080 0000a488 .rela.opd
9 RELA 400000000004d508 000000000004d508 000058e0 .rela.data.rel
10 RELA 4000000000052de8 0000000000052de8 000005e8 .rela.data.rel.ro.local
11 RELA 40000000000533d0 00000000000533d0 000002d0 .rela.data
12 RELA 40000000000536a0 00000000000536a0 00007308 .rela.plt
13 UNWI 400000000005a9a8 000000000005a9a8 00008560 .PARISC.unwind
14 PBIT 4000000000062f08 0000000000062f08 00017a08 .rodata
15 PBIT 400000000007a910 000000000007a910 00000000 $UNWIND$MILLICODE$
16 PBIT 400000000007a910 000000000007a910 00002794 .dynhash
17 PBIT 400000000007d0a8 000000000007d0a8 00133378 .text
18 PBIT 8000000100000000 00000000001b1000 00006810 .data
19 PBIT 8000000100006810 00000000001b7810 00004028 .data.rel.local
20 PBIT 800000010000a838 00000000001bb838 00000c60 .data.rel.ro
21 PBIT 800000010000b498 00000000001bc498 00002728 .data.rel
22 PBIT 800000010000dbc0 00000000001bebc0 00000228 .data.rel.ro.local
23 PBIT 800000010000dde8 00000000001bede8 00006dc0 .opd
24 PBIT 8000000100014ba8 00000000001c5ba8 00004cb0 .plt
25 PBIT 8000000100019858 00000000001ca858 00008d90 .dlt
26 PBIT 80000001000225e8 00000000001d35e8 00000000 .HP.init
27 PBIT 80000001000225e8 00000000001d35e8 00000000 .preinit
28 PBIT 80000001000225e8 00000000001d35e8 00000000 .init
29 PBIT 80000001000225e8 00000000001d35e8 00000000 .fini
30 NOBI 80000001000225f0 00000000001d35e8 000032b0 .bss
31 NOBI 80000001000258a0 00000000001d35e8 00000000 .hbss
32 NOBI 80000001000258a0 00000000001d35e8 00000000 .tbss
33 NOTE 0000000000000000 00000000001d35e8 00000780 .note
34 PBIT 0000000000000000 00000000001d3d68 0000a9bd .debug_abbrev
35 PBIT 000000000000a9bd 00000000001de725 000e40a3 .debug_info
36 PBIT 00000000000eea60 00000000002c27c8 00018a5d .debug_line
37 PBIT 00000000001074bd 00000000002db225 0000b714 .debug_pubnames
38 PBIT 0000000000112bd1 00000000002e6939 00000d50 .debug_aranges
39 PBIT 0000000000113921 00000000002e7689 00004d76 .debug_str
40 PBIT 0000000000118697 00000000002ec3ff 000004fe .comment
41 PBIT 0000000000118b95 00000000002ec8fd 00000960 .debug_ranges
42 PBIT 00000000001194f5 00000000002ed25d 00000000 .btext
43 PBIT 00000000001194f5 00000000002ed25d 00000000 .bdata
44 STRT 0000000000000000 00000000002ed260 00014529 .strtab
45 SYMT 0000000000000000 0000000000301790 0002a108 .symtab
46 STRT 0000000000000000 000000000032b898 000001e3 .shstrtab

I'm not sure what else to look for in terms of dependencies. Is there any way to "test" the mod_perl.so library outside of trying to load it in Apache? I'm curious if it's an overall problem or just one with Apache. I just don't get how I could compile both program back to back using the same gcc and make (and presumably all the same libraries), and something isn't right.

Thanks.
ranganath ramachandra
Esteemed Contributor

Re: mod_perl exec format error

as i said, ldd will show you the other shared libraries that mod_perl.so depends on if any.

you can also try a simple program like this (run as a shell script):
[----
cat > test.c << @EOF
#include
#include
#include
main ()
{
void *dl = dlopen("mod_perl.so",RTLD_LAZY);
if (dl==NULL) {
puts(dlerror());
} else {
puts("success");
dlclose(dl);
}
}
@EOF
cc +DD64 test.c -ldl -o test
./test
----]

if mod_perl.so depends on something like libpthread.1 that has TLS in it, you will see a message like

[----
Cannot dlopen load module '/usr/lib/pa20_64/libpthread.1' because it contains thread specific data.
----]

in such a case the workaround is to run the test with LD_PRELOAD_ONCE set to a colon-separated list of the paths such shared libraries:

LD_PRELOAD_ONCE=/usr/lib/pa20_64/libpthread.1 ./test

this is not specific to apache, it is a limitation in the TLS implementation and can affect even the simple test case above.
 
--
ranga
[i work for hpe]

Accept or Kudo

Michael Simone
Frequent Advisor

Re: mod_perl exec format error

Ranganath, you're my favorite person this weekend. Your sample program was the key--I tried that, and it errored out with a message indicating a problem with loading libcl.2 because it contained thread data. That information led me to find some posts on Google related to problems loading other DSOs (not mod_perl) into Apache, and suggested rebuilding Apache with libcl and libpthread included. So I did this before reconfiguring Apache:

export LDFLAGS=' -lcl -lpthread -L/usr/local/lib -L/lib/pa20_64 '

Rebuilt Apache, then rebuilt mod_perl, and everything looks good now. Thanks VERY much for the tips. More points awarded.
ranganath ramachandra
Esteemed Contributor
Solution

Re: mod_perl exec format error

thanks, glad it helped :)
 
--
ranga
[i work for hpe]

Accept or Kudo