Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling go-yara with gccgo on AIX #59

Closed
Codehardt opened this issue Jan 9, 2020 · 1 comment
Closed

Compiling go-yara with gccgo on AIX #59

Codehardt opened this issue Jan 9, 2020 · 1 comment

Comments

@Codehardt
Copy link

Hi,

I tried to compile go-yara on AIX 7.2 POWER7 (ppc64) but I get the following error:

bash-5.0$ CGO_LDFLAGS="-L/usr/local/lib -lyara" CGO_CFLAGS="-I/usr/local/include" go.gcc build --gccgoflags="-Xlinker -bbigtoc" -o out -mod vendor -tags="no_pkg_config" aixtest/main.go

ld: 0711-317 FEHLER: Nicht definiertes Symbol: .yr_compiler_add_string
ld: 0711-317 FEHLER: Nicht definiertes Symbol: .yr_compiler_create
ld: 0711-317 FEHLER: Nicht definiertes Symbol: .yr_compiler_define_boolean_variable
ld: 0711-317 FEHLER: Nicht definiertes Symbol: .yr_compiler_define_float_variable
ld: 0711-317 FEHLER: Nicht definiertes Symbol: .yr_compiler_define_integer_variable
ld: 0711-317 FEHLER: Nicht definiertes Symbol: .yr_compiler_define_string_variable
...

Using -Xlinker -bnoquiet shows me the following information on top of the error:

(ld): setopt 64
(ld): halt 4
(ld): setopt r/o->w
(ld): setopt bigtoc
(ld): setfflag 4
(ld): savename $WORK/b001/exe/a.out
(ld): filelist 12 1
(ld): i /lib/crt0_64.o
(ld): i /opt/freeware/lib/gcc/powerpc-ibm-aix7.2.0.0/9.1.0/ppc64/crtcxa.o
(ld): i /opt/freeware/lib/gcc/powerpc-ibm-aix7.2.0.0/9.1.0/ppc64/crtdbase.o
(ld): i $WORK/b001/_pkg_.a
(ld): i $WORK/b001/_pkg1_.a
(ld): lib /usr/local/lib/libyara.a
(ld): lib /opt/freeware/lib/gcc/powerpc-ibm-aix7.2.0.0/9.1.0/ppc64/libgobegin.a
(ld): lib /opt/freeware/lib/gcc/powerpc-ibm-aix7.2.0.0/9.1.0/ppc64/libgo.a
(ld): lib /usr/lib/libm.a
(ld): lib /opt/freeware/lib/gcc/powerpc-ibm-aix7.2.0.0/9.1.0/ppc64/libgcc_s.a
(ld): i /opt/freeware/lib/gcc/powerpc-ibm-aix7.2.0.0/9.1.0/ppc64/libgcc.a
(ld): lib /usr/lib/libc.a
LIBRARY: Gemeinsam genutztes Objekt libgo.a[libgo.so.14]: Es wurden 44098 Symbole importiert.
LIBRARY: Gemeinsam genutztes Objekt libgcc_s.a[shr.o]: Es wurden 151 Symbole importiert.
LIBRARY: Gemeinsam genutztes Objekt libc.a[shr_64.o]: Es wurden 3148 Symbole importiert.
LIBRARY: Gemeinsam genutztes Objekt libc.a[posix_aio_64.o]: Es wurden 20 Symbole importiert.
LIBRARY: Gemeinsam genutztes Objekt libc.a[aio_64.o]: Es wurden 18 Symbole importiert.
LIBRARY: Gemeinsam genutztes Objekt libc.a[pse_64.o]: Es wurden 8 Symbole importiert.
LIBRARY: Gemeinsam genutztes Objekt libc.a[dl_64.o]: Es wurden 4 Symbole importiert.
LIBRARY: Gemeinsam genutztes Objekt libc.a[pty_64.o]: Es wurden 1 Symbole importiert.
LIBRARY: Gemeinsam genutztes Objekt libc.a[cthread_64.o]: Es wurden 25 Symbole importiert.
LIBRARY: Gemeinsam genutztes Objekt libc.a[uchar_64.o]: Es wurden 4 Symbole importiert.
FILELIST: Anzahl der zuvor eingefügten Dateien, die verarbeitet wurden: 12
(ld): resolve
RESOLVE: 1680 von 55377 Symbolen wurden beibehalten.
(ld): addgl /usr/lib/glinkl64.o
ADDGL: Es wurde Glink-Code für 131 Symbole hinzugefügt.
(ld): er full
ld: 0711-318 FEHLER: Es wurden nicht definierte Symbole gefunden.
        Die folgenden Symbole sind fehlerhaft:

libyara (3.11.0) was installed with ./bootstrap.sh && ./configure --disable-shared --disable-magic --disable-cuckoo --enable-dotnet && make && make install

It was installed to:

  • /usr/local/lib
  • /usr/local/include
  • /usr/local/bin
ls /usr/local/lib /usr/local/include
/usr/local/include:
yara  yara.h

/usr/local/lib:
libyara.a  libyara.la  pkgconfig
/usr/local/bin/yara --version
3.11.0
ar -t /usr/local/lib/libyara.a
tests.o
pe.o
elf.o
math.o
time.o
pe_utils.o
hash.o
dotnet.o
grammar.o
ahocorasick.o
arena.o
atoms.o
bitmask.o
compiler.o
endian.o
exec.o
exefiles.o
filemap.o
lt1-hash.o
hex_grammar.o
hex_lexer.o
lexer.o
libyara.o
mem.o
modules.o
object.o
parser.o
proc.o
re.o
re_grammar.o
re_lexer.o
rules.o
scan.o
scanner.o
sizedstr.o
stack.o
stopwatch.o
strutils.o
stream.o
threading.o
none.o

There are no more libyaras installed:

find / -name "libyara.a"
/home/user/yara-3.11.0/libyara/.libs/libyara.a
/usr/local/lib/libyara.a
find / -name "yara.h"
/home/user/yara-3.11.0/libyara/include/yara.h
/usr/local/include/yara.h

I also tried using pkg-config but this results in same error.

go.gcc version
go version go1.12.2 gccgo (GCC) 9.1.0 aix/ppc64
git -C vendor/github.com/hillu/go-yara/ log | head -n 1
commit 510cc23f05d05782d7f600ee26154542127e6281

Do you know what I am doing wrong here?

Thanks.

@Codehardt
Copy link
Author

After tons of painful hours I was able to solve this problem. The problem was that libyara was compiled in 32 bit version.

Days ago I used

nm -g /usr/local/lib/libyara.a

to check, whether all required symbols can be found in libyara.

Now I noticed that there is a -X32 / -X64 flag for nm. With -X64, no symbols were exported.

I reconfigured and rebuild YARA with CFLAGS="-maix64" and OBJECT_MODE=64 and now it's working.

Kind regards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant