radareorg / radare2

UNIX-like reverse engineering framework and command-line toolset
https://www.radare.org/
GNU Lesser General Public License v3.0
20.78k stars 3.01k forks source link

sys/install.sh #2456

Closed alvarofe closed 9 years ago

alvarofe commented 9 years ago

When I try to compile r2 with asan support I get the following.

alvaro_fe@macbook 10:57 ~/Projects/Reverse/radare2/r2 ./sys/asan.sh                                                                                                                            [dev] git:r2
/Users/alvaro_fe/Projects/Reverse/radare2/r2/sys/install.sh: line 8: cd: /Users/alvaro_fe/Projects/Reverse/radare2/r2//Users/alvaro_fe/Projects/Reverse/radare2/r2/sys: No such file or directory
/Users/alvaro_fe/Projects/Reverse/radare2/r2/sys/install.sh: line 29: ./sys/build.sh: No such file or directory

https://github.com/radare/radare2/blob/master/sys/install.sh#L8

radare commented 9 years ago

Try this patch. its unfinished, just a poc.

http://lolcathost.org/b/p

alvarofe commented 9 years ago

Now it lets me to compile :) though I am not able to get ASan works but that is my problem not r2.

Thanks!

radare commented 9 years ago

Remove the -lasan from the .sh

On 28 Apr 2015, at 18:56, Álvaro Felipe Melchor notifications@github.com wrote:

Now it lets me to compile :) though I am not able to get ASan works but that is my problem not r2.

Thanks!

— Reply to this email directly or view it on GitHub.

alvarofe commented 9 years ago

I already did, the problem that appears is

ar: creating archive libr_z.a
Undefined symbols for architecture x86_64:
  "___asan_init_v5", referenced from:
      _asan.module_ctor in adler32.o
      _asan.module_ctor in crc32.o
      _asan.module_ctor in deflate.o
      _asan.module_ctor in infback.o
      _asan.module_ctor in inffast.o
      _asan.module_ctor in inflate.o
      _asan.module_ctor in inftrees.o
      ...
  "___asan_memcpy", referenced from:
      _fill_window in deflate.o
      _flush_pending in deflate.o
      _deflateCopy in deflate.o
      _read_buf in deflate.o
      _inflateBack in infback.o
      _inflate_fast in inffast.o
      _inflate in inflate.o
      ...

But I assume that some library is not able to find. I installed llvm36 from brew with ASan support

XVilka commented 9 years ago

@alvarofe looks like you need to build shlr/zip with an ASAN too.

radare commented 9 years ago

I think that all those issues comes from the bug introduced by @Maijin in 3b26388769fd7771da6df6d8da1dca8d7f21521c can you confirm. just removing the quotes around $@ should make it happy

radare commented 9 years ago

confirmed. @Maijin fix that with your $* magic

alvarofe commented 9 years ago

The commit https://github.com/radare/radare2/commit/6aefa441b118f183144a70cc94bae2e7ecf07e66 it seems that at least for me doesn't fix nothing. The issue is that in the line below clang -dynamic at the end lacks the flag -fsanitize=address. It also fails with sdb so I assume is in the moment when r2 creates dynamic libraries the flag is not passed in the correct way.

clang-3.6 -c -fsanitize=address -fsanitize=address -MD   -fPIC -g -Wall -D__UNIX__=1 -fPIC -I../../../libr/include -I../include/ -o zip_string.o zip_string.c
clang-3.6 -c -fsanitize=address -fsanitize=address -MD   -fPIC -g -Wall -D__UNIX__=1 -fPIC -I../../../libr/include -I../include/ -o zip_unchange.o zip_unchange.c
clang-3.6 -c -fsanitize=address -fsanitize=address -MD   -fPIC -g -Wall -D__UNIX__=1 -fPIC -I../../../libr/include -I../include/ -o zip_unchange_all.o zip_unchange_all.c
clang-3.6 -c -fsanitize=address -fsanitize=address -MD   -fPIC -g -Wall -D__UNIX__=1 -fPIC -I../../../libr/include -I../include/ -o zip_unchange_archive.o zip_unchange_archive.c
clang-3.6 -c -fsanitize=address -fsanitize=address -MD   -fPIC -g -Wall -D__UNIX__=1 -fPIC -I../../../libr/include -I../include/ -o zip_unchange_data.o zip_unchange_data.c
clang-3.6 -c -fsanitize=address -fsanitize=address -MD   -fPIC -g -Wall -D__UNIX__=1 -fPIC -I../../../libr/include -I../include/ -o zip_utf-8.o zip_utf-8.c
clang-3.6   -dynamic -L../../../libr/util -fPIC -shared -o libr_zip.dylib zip_add.o zip_add_dir.o zip_add_entry.o zip_close.o zip_delete.o zip_dir_add.o zip_dirent.o zip_discard.o zip_entry.o zip_err_str.
o zip_error.o zip_error_clear.o zip_error_get.o zip_error_get_sys_type.o zip_error_strerror.o zip_error_to_str.o zip_extra_field.o zip_extra_field_api.o zip_fclose.o zip_fdopen.o zip_file_add.o zip_file_e
rror_clear.o zip_file_error_get.o zip_file_get_comment.o zip_file_get_offset.o zip_file_rename.o zip_file_replace.o zip_file_set_comment.o zip_file_strerror.o zip_filerange_crc.o zip_fopen.o zip_fopen_enc
rypted.o zip_fopen_index.o zip_fopen_index_encrypted.o zip_fread.o zip_get_archive_comment.o zip_get_archive_flag.o zip_get_compression_implementation.o zip_get_encryption_implementation.o zip_get_file_co
mment.o zip_get_num_entries.o zip_get_num_files.o zip_get_name.o zip_memdup.o zip_name_locate.o zip_new.o zip_open.o zip_rename.o zip_replace.o zip_set_archive_comment.o zip_set_archive_flag.o zip_set_def
ault_password.o zip_set_file_comment.o zip_set_file_compression.o zip_set_name.o zip_source_buffer.o zip_source_close.o zip_source_crc.o zip_source_deflate.o zip_source_error.o zip_source_file.o zip_sourc
e_filep.o zip_source_free.o zip_source_function.o zip_source_layered.o zip_source_open.o zip_source_pkware.o zip_source_pop.o zip_source_read.o zip_source_stat.o zip_source_window.o zip_source_zip.o zip_s
ource_zip_new.o zip_stat.o zip_stat_index.o zip_stat_init.o zip_strerror.o zip_string.o zip_unchange.o zip_unchange_all.o zip_unchange_archive.o zip_unchange_data.o zip_utf-8.o ../zlib/libr_z.a
Undefined symbols for architecture x86_64:
  "___asan_init_v5", referenced from:
      _asan.module_ctor in zip_add.o
      _asan.module_ctor in zip_add_dir.o
      _asan.module_ctor in zip_add_entry.o
      _asan.module_ctor in zip_close.o
      _asan.module_ctor in zip_delete.o
      _asan.module_ctor in zip_dir_add.o
      _asan.module_ctor in zip_dirent.o
      ...
Maijin commented 9 years ago

@alvarofe Does this work at 7ff53f8ae0906a659be613aac78008c126029342 ?

alvarofe commented 9 years ago

Neither :( Am I the only one having this issue?

radare commented 9 years ago

Yup. Nobody else can reproduce it. Sorry

alvarofe commented 9 years ago

:'(

XVilka commented 9 years ago

@alvarofe can you try with a completely clean tree?

alvarofe commented 9 years ago

git clean -xdf?

jjdredd commented 9 years ago

I could have had a similar issue, will check later.

jjdredd commented 9 years ago

i get stuff like this

json.o: In function `sdb_json_unindent':
json.c:(.text+0x4724): undefined reference to `__asan_report_load1'
json.c:(.text+0x4763): undefined reference to `__asan_report_load1'
json.c:(.text+0x47eb): undefined reference to `__asan_report_store1'
json.c:(.text+0x47f9): undefined reference to `__asan_report_store1'
json.c:(.text+0x4855): undefined reference to `__asan_report_load1'
json.c:(.text+0x48ae): undefined reference to `__asan_report_load1'
json.c:(.text+0x48fb): undefined reference to `__asan_report_store1'
json.c:(.text+0x4944): undefined reference to `__asan_report_load1'

after I did this, ofc

diff --git a/sys/install.sh b/sys/install.sh
index 9e53403..4822483 100755
--- a/sys/install.sh
+++ b/sys/install.sh
@@ -5,7 +5,7 @@ gmake --help >/dev/null 2>&1
 [ $? = 0 ] && MAKE=gmake

 # find root
-cd `dirname $PWD/$0` ; cd ..
+cd `dirname $0` ; cd ..

 # update
 if [ "$1" != "--without-pull" ]; then
radare commented 9 years ago

This is known and harmless

On 29 Apr 2015, at 15:43, Judge_Dredd notifications@github.com wrote:

i get stuff like this

json.o: In function sdb_json_unindent': json.c:(.text+0x4724): undefined reference toasan_report_load1' json.c:(.text+0x4763): undefined reference to `asan_report_load1' json.c:(.text+0x47eb): undefined reference to__asan_report_store1' json.c:(.text+0x47f9): undefined reference toasan_report_store1' json.c:(.text+0x4855): undefined reference to`asan_report_load1' json.c:(.text+0x48ae): undefined reference to __asan_report_load1' json.c:(.text+0x48fb): undefined reference toasan_report_store1' json.c:(.text+0x4944): undefined reference to `asan_report_load1' — Reply to this email directly or view it on GitHub.

crowell commented 9 years ago

to build with asan why not just do like CC="clang -fsanitize=address" ./sys/install.sh ?

alvarofe commented 9 years ago

I've just tried and it doesn't fail @crowell . I thought I tried before but it seems that I was doing something wrong with that :) Thanks \o/ !!

radare commented 9 years ago

Should be fixed now

On 30 Apr 2015, at 23:12, Álvaro Felipe Melchor notifications@github.com wrote:

I've just tried and it doesn't fail @crowell . I thought I tried before but it seems that I was doing something wrong with that :) Thanks \o/ !!

— Reply to this email directly or view it on GitHub.

dequis commented 9 years ago

c578539c1b27d38f583526364449bf9eea99106b fixes the issue mentioned in the original description, and i'm not really sure if there are other issues mentioned here.