Expose R_WEAK attribute and minor cleanups

* Fix memleak in cbin.relocs
This commit is contained in:
pancake 2022-03-16 01:32:15 +01:00 committed by pancake
parent 9598fe5592
commit 81c9013454
6 changed files with 15 additions and 11 deletions

View File

@ -338,6 +338,7 @@ R_API bool r_bin_open_io(RBin *bin, RBinFileOptions *opt) {
opt->filename = fname;
bool res = r_bin_open_buf (bin, buf, opt);
r_buf_free (buf);
//if (!res) { r_buf_free (buf); }
return res;
}

View File

@ -2013,10 +2013,10 @@ ut64 Elf_(r_bin_elf_get_main_offset)(ELFOBJ *bin) {
st32 maindelta = (st32)r_read_le32 (p);
ut64 vmain = (ut64)(entry + bo + maindelta) + 7;
ut64 ventry = Elf_(r_bin_elf_p2v) (bin, entry);
if (vmain>>16 == ventry>>16) {
if ((vmain >> 16) == (ventry >> 16)) {
return (ut64)vmain;
}
} else if (0xc7) { // mov rdi, 0xADDR
} else if (ch == 0xc7) { // mov rdi, 0xADDR
ut8 *p = buf + bo + 3;
return (ut64)(ut32)r_read_le32 (p);
}
@ -3778,7 +3778,7 @@ static RBinElfSymbol* Elf_(_r_bin_elf_get_symbols_imports)(ELFOBJ *bin, int type
} else if (st_name <= 0 || st_name >= maxsize) {
ret[ret_ctr].name[0] = 0;
} else {
r_str_ncpy(ret[ret_ctr].name, &strtab[st_name], ELF_STRING_LENGTH - 1);
r_str_ncpy (ret[ret_ctr].name, &strtab[st_name], ELF_STRING_LENGTH - 1);
ret[ret_ctr].type = type2str (bin, &ret[ret_ctr], &sym[k]);
if (ht_pp_find (symbol_map, &ret[ret_ctr], NULL)) {

View File

@ -40,11 +40,6 @@
#define R_NULLABLE /* pointer can be null */
#define R_DEPRECATE /* should not be used in new code and should/will be removed in the future */
#define R_IFNULL(x) /* default value for the pointer when null */
#ifdef __GNUC__
#define R_UNUSED __attribute__((__unused__))
#else
#define R_UNUSED /* unused */
#endif
#ifdef R_NEW
#undef R_NEW

View File

@ -212,6 +212,14 @@ typedef struct _utX {
#define R_PACKED( __Declaration__ ) __Declaration__ __attribute__((__packed__))
#endif
#ifdef __GNUC__
#define R_UNUSED __attribute__((__unused__))
#define R_WEAK __attribute__ ((weak))
#else
#define R_UNUSED /* unused */
#define R_WEAK /* weak */
#endif
#if APPLE_SDK_IPHONESIMULATOR
#undef LIBC_HAVE_FORK
#define LIBC_HAVE_FORK 0

View File

@ -1,4 +1,4 @@
/* radare - LGPL - Copyright 2008-2021 - pancake */
/* radare - LGPL - Copyright 2008-2022 - pancake */
#ifndef R2_UTIL_H
#define R2_UTIL_H
@ -87,7 +87,7 @@ int gettimeofday (struct timeval* p, void* tz);
extern "C" {
#endif
R_LIB_VERSION_HEADER(r_util);
R_LIB_VERSION_HEADER (r_util);
#ifdef __cplusplus
}
#endif

View File

@ -1,4 +1,4 @@
/* radare2 - LGPL - Copyright 2018-2020 - ret2libc */
/* radare2 - LGPL - Copyright 2018-2022 - ret2libc */
#include <r_util.h>