pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedbinary operators / C func getting "invalid ELF header"
6+ messages / 4 participants
[nested] [flat]
* binary operators / C func getting "invalid ELF header"
@ 1999-01-19 00:51 Michael Olivier <molivier@yahoo.com>
1999-01-19 01:47 ` Re: [SQL] binary operators / C func getting "invalid ELF header" Gene Selkov Jr. <selkovjr@mcs.anl.gov>
0 siblings, 1 reply; 6+ messages in thread
From: Michael Olivier @ 1999-01-19 00:51 UTC (permalink / raw)
To: pgsql-sql
Hi folks,
I need to do a complex bitwise operation on integers during a select
query such as:
select acctname from users U where func(U.flags, 27) = 0;
The function in C is:
result = (~A) & (A ^ B)
I didn't see any bitwise operations like AND and XOR in the postgres
doc -- if they're there, I apologize and would love a pointer to the
doc.
Otherwise, I've gone down the path of trying to write a C function to
do this... and am getting this error:
db=> select not_a_and__a_xor_b(1,1);
ERROR: Load of file /home/michael/sql/funcs.so failed:
¨¸t@¨¸t@chael/sql/funcs.so: invalid ELF header
I'm compiling with the -fpic option for Linux (under gcc)
cc -c -O2 -fpic -g -I. -I./include -I. -I./include -c funcs.c -o
funcs.o
/bin/rm -f funcs.so
/usr/bin/ar cr funcs.so funcs.o
Can someone tell me the step(s) I'm missing or what to try next? I've
tested the C code - works fine (included below).
thanks,
--Michael
------------------------------------------------
//
// functions used within postgres
//
#include "postgres.h" /* for char16, etc. */
int
not_a_and__a_xor_b(int A, int B)
{
return (~A) & (A ^ B);
}
_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: [SQL] binary operators / C func getting "invalid ELF header"
1999-01-19 00:51 binary operators / C func getting "invalid ELF header" Michael Olivier <molivier@yahoo.com>
@ 1999-01-19 01:47 ` Gene Selkov Jr. <selkovjr@mcs.anl.gov>
0 siblings, 0 replies; 6+ messages in thread
From: Gene Selkov Jr. @ 1999-01-19 01:47 UTC (permalink / raw)
To: Michael Olivier <molivier@yahoo.com>; pgsql-sql
>
> I've gone down the path of trying to write a C function to
> do this... and am getting this error:
>
> db=3D> select not_a_and__a_xor_b(1,1);
> ERROR: Load of file /home/michael/sql/funcs.so failed:
> =A8=B8t@=A8=B8t@chael/sql/funcs.so: invalid ELF header
>
> I'm compiling with the -fpic option for Linux (under gcc)
>
> cc -c -O2 -fpic -g -I. -I./include -I. -I./include -c funcs.c -o
> funcs.o
> /bin/rm -f funcs.so
> /usr/bin/ar cr funcs.so funcs.o =20
Try to adapt the Makefile from src/tutorial to your purposes. Make sure it includes the right
rules by changing
SRCDIR= ..
include ../Makefile.global
to:
SRCDIR= /path/to/your/postgres/source/tree/src
include $(SRCDIR)/Makefile.global
Then name your target files in $(DLOBJS).
You may also want to note the sed rules that substitute anchors such
as _OBJWD_ with the absolute path. They make your sql scripts more
portable (see funcs.source for example.
--Gene
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: [SQL] binary operators / C func getting "invalid ELF header"
@ 1999-01-19 03:18 Gregory W Burnham <gburnham@sfu.ca>
0 siblings, 0 replies; 6+ messages in thread
From: Gregory W Burnham @ 1999-01-19 03:18 UTC (permalink / raw)
To: pgsql-sql
>> I've gone down the path of trying to write a C function to
>> do this... and am getting this error:
>>
>> db=3D> select not_a_and__a_xor_b(1,1);
>> ERROR: Load of file /home/michael/sql/funcs.so failed:
>> =A8=B8t@=A8=B8t@chael/sql/funcs.so: invalid ELF header
>>
>> I'm compiling with the -fpic option for Linux (under gcc)
>>
>> cc -c -O2 -fpic -g -I. -I./include -I. -I./include -c funcs.c -o
>> funcs.o
>> /bin/rm -f funcs.so
>> /usr/bin/ar cr funcs.so funcs.o =20
Here's an except from my make file, and I've
had not problem (so far) with the functions.
cc -c -I/usr/include/pgsql functions/functions.c -o functions/functions.o
ld -shared -o /tmp/functions.so functions/functions.o
Gregory W Burnham
Software Engineer
Excite Labs
Faculty Of Education
Simon Fraser University
Vancouver, BC, V5A 1S6
604 291 3615 (ph)
604 291 5679 (fx)
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: [SQL] binary operators / C func getting "invalid ELF header"
@ 1999-01-19 19:15 Michael Olivier <molivier@yahoo.com>
0 siblings, 0 replies; 6+ messages in thread
From: Michael Olivier @ 1999-01-19 19:15 UTC (permalink / raw)
To: Gregory W Burnham <gburnham@sfu.ca>; pgsql-sql
Thanks a lot, Gregory - that did the trick.
Gene -- Thanks also for your response.
--Michael
---Gregory W Burnham <gburnham@sfu.ca> wrote:
>
> >> I've gone down the path of trying to write a C function to
> >> do this... and am getting this error:
> >>
> >> db=3D> select not_a_and__a_xor_b(1,1);
> >> ERROR: Load of file /home/michael/sql/funcs.so failed:
> >> =A8=B8t@=A8=B8t@chael/sql/funcs.so: invalid ELF header
> >>
> >> I'm compiling with the -fpic option for Linux (under gcc)
> >>
> >> cc -c -O2 -fpic -g -I. -I./include -I. -I./include -c
funcs.c -o
> >> funcs.o
> >> /bin/rm -f funcs.so
> >> /usr/bin/ar cr funcs.so funcs.o =20
>
> Here's an except from my make file, and I've
> had not problem (so far) with the functions.
>
> cc -c -I/usr/include/pgsql functions/functions.c -o
functions/functions.o
> ld -shared -o /tmp/functions.so functions/functions.o
>
> Gregory W Burnham
> Software Engineer
> Excite Labs
> Faculty Of Education
> Simon Fraser University
> Vancouver, BC, V5A 1S6
> 604 291 3615 (ph)
> 604 291 5679 (fx)
>
>
>
>
_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com
^ permalink raw reply [nested|flat] 6+ messages in thread
* RE: [SQL] binary operators / C func getting "invalid ELF header"
@ 1999-01-19 20:46 Jackson, DeJuan <djackson@cpsgroup.com>
0 siblings, 0 replies; 6+ messages in thread
From: Jackson, DeJuan @ 1999-01-19 20:46 UTC (permalink / raw)
To: Michael Olivier <molivier@yahoo.com>; pgsql-sql
> -----Original Message-----
> result = (~A) & (A ^ B)
I see you got the answer to your question but isn't this the same as
result = (~A) & B
^ permalink raw reply [nested|flat] 6+ messages in thread
* RE: [SQL] binary operators / C func getting "invalid ELF header"
@ 1999-01-20 19:05 Michael Olivier <molivier@yahoo.com>
0 siblings, 0 replies; 6+ messages in thread
From: Michael Olivier @ 1999-01-20 19:05 UTC (permalink / raw)
To: Jackson, DeJuan <djackson@cpsgroup.com>; pgsql-sql
"Jackson, DeJuan" <djackson@cpsgroup.com> wrote:
>
> > result = (~A) & (A ^ B)
> I see you got the answer to your question but isn't this the same as
> result = (~A) & B
Yes, thanks. Now it looks obvious :)
--M
_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~1999-01-20 19:05 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-01-19 00:51 binary operators / C func getting "invalid ELF header" Michael Olivier <molivier@yahoo.com>
1999-01-19 01:47 ` Gene Selkov Jr. <selkovjr@mcs.anl.gov>
1999-01-19 03:18 Re: [SQL] binary operators / C func getting "invalid ELF header" Gregory W Burnham <gburnham@sfu.ca>
1999-01-19 19:15 Re: [SQL] binary operators / C func getting "invalid ELF header" Michael Olivier <molivier@yahoo.com>
1999-01-19 20:46 RE: [SQL] binary operators / C func getting "invalid ELF header" Jackson, DeJuan <djackson@cpsgroup.com>
1999-01-20 19:05 RE: [SQL] binary operators / C func getting "invalid ELF header" Michael Olivier <molivier@yahoo.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox