rabin2 could not detect go in macho binaries (#16993)

* rabin2 could not detect go in non-elf binaries

* better comparison for go detection

* updates based on suggestions by ret2libc. re-tested accordingly after updates

* updates based on suggestions by ret2libc. re-tested accordingly after updates

Co-authored-by: Alex Useche <alex.useche@nvisium.com>
This commit is contained in:
DharmaCode 2020-06-03 09:55:26 -06:00 committed by GitHub
parent a14f5c0777
commit e3a289d454
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,6 +40,10 @@ static bool check_swift(RBinSymbol *sym) {
return false;
}
static bool check_golang(RBinSymbol *sym) {
return !strncmp (sym->name, "go.", 3);
}
static inline bool is_cxx_symbol (const char *name) {
r_return_val_if_fail (name, false);
if (!strncmp (name, "_Z", 2)) {
@ -106,6 +110,10 @@ R_API int r_bin_load_languages(RBinFile *binfile) {
return R_BIN_NM_RUST;
}
}
if (check_golang (sym)) {
info->lang = "go";
return R_BIN_NM_GO;
}
if (!cantbe.swift) {
bool hasswift = false;
if (!swiftIsChecked) {
@ -213,6 +221,8 @@ R_API const char *r_bin_lang_tostring(int lang) {
switch (lang & 0xffff) {
case R_BIN_NM_SWIFT:
return "swift";
case R_BIN_NM_GO:
return "go";
case R_BIN_NM_JAVA:
return "java";
case R_BIN_NM_KOTLIN: