Skip to content

Commit

Permalink
i#3348 sym conflicts: Rename one-word global symbols, part 2
Browse files Browse the repository at this point in the history
Renames more single-word global symbols to help reduce the chance
of name conflicts:

+ s/initstack/d_r_initstack/
+ s/loginst/d_r_loginst/
+ s/logopnd/d_r_logopnd/
+ s/logtrace/d_r_logtrace/
+ s/mangle/d_r_mangle/
+ s/mangle/d_r_mangle/
+ s/MD5Init/d_r_md5_init/
+ s/MD5Final/d_r_md5_final/
+ s/MD5Update/d_r_md5_update/
+ s/notify/d_r_notify/
+ s/stackdump/d_r_stackdump/
+ s/stats/d_r_stats/

Issue: #3348
  • Loading branch information
derekbruening committed Mar 2, 2019
1 parent ed0b965 commit feea1d6
Show file tree
Hide file tree
Showing 58 changed files with 781 additions and 746 deletions.
14 changes: 1 addition & 13 deletions core/CMake_symbol_check.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,7 @@ foreach(line ${lines})
set(is_ok OFF)
# We have some legacy exceptions we allow until we've renamed them all.
if (line MATCHES "decode\n" OR
line MATCHES "disassemble\n" OR
line MATCHES "initstack\n" OR
line MATCHES "loginst\n" OR
line MATCHES "logopnd\n" OR
line MATCHES "logtrace\n" OR
line MATCHES "mangle\n" OR
line MATCHES "MD5Final\n" OR
line MATCHES "MD5Init\n" OR
line MATCHES "MD5Update\n" OR
line MATCHES "notify\n" OR
line MATCHES "regparms\n" OR
line MATCHES "stackdump\n" OR
line MATCHES "stats\n")
line MATCHES "disassemble\n")
# OK: an exception we allow for now.
set(is_ok ON)
endif ()
Expand Down
4 changes: 2 additions & 2 deletions core/annotations.c
Original file line number Diff line number Diff line change
Expand Up @@ -1091,9 +1091,9 @@ annotation_printf(const char *format, ...)
char *timestamped_format = NULL;
uint buffer_length = 0;

if (stats == NULL || stats->loglevel == 0)
if (d_r_stats == NULL || d_r_stats->loglevel == 0)
return 0; /* No log is available for writing. */
if ((stats->logmask & LOG_VIA_ANNOTATIONS) == 0)
if ((d_r_stats->logmask & LOG_VIA_ANNOTATIONS) == 0)
return 0; /* Filtered out by the user. */

/* Substitute the first instance of the timestamp token with a timestamp string.
Expand Down
9 changes: 5 additions & 4 deletions core/arch/aarch64/aarch64.asm
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* **********************************************************
* Copyright (c) 2019 Google, Inc. All rights reserved.
* Copyright (c) 2016 ARM Limited. All rights reserved.
* **********************************************************/

Expand Down Expand Up @@ -318,7 +319,7 @@ cat_done_saving_dstack:
cat_thread_only:
CALLC0(GLOBAL_REF(dynamo_thread_exit))
cat_no_thread:
/* switch to initstack for cleanup of dstack */
/* switch to d_r_initstack for cleanup of dstack */
adrp x26, :got:initstack_mutex
ldr x26, [x26, #:got_lo12:initstack_mutex]
cat_spin:
Expand All @@ -329,15 +330,15 @@ cat_spin:

cat_have_lock:
/* switch stack */
adrp x0, :got:initstack
ldr x0, [x0, #:got_lo12:initstack]
adrp x0, :got:d_r_initstack
ldr x0, [x0, #:got_lo12:d_r_initstack]
ldr x0, [x0]
mov sp, x0

/* free dstack and call the EXIT_DR_HOOK */
CALLC1(GLOBAL_REF(dynamo_thread_stack_free_and_exit), x24) /* pass dstack */

/* give up initstack mutex */
/* give up initstack_mutex */
adrp x0, :got:initstack_mutex
ldr x0, [x0, #:got_lo12:initstack_mutex]
mov x1, #0
Expand Down
7 changes: 4 additions & 3 deletions core/arch/aarch64/clean_call_opt.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* **********************************************************
* Copyright (c) 2019 Google, Inc. All rights reserved.
* Copyright (c) 2016-2018 ARM Limited. All rights reserved.
* **********************************************************/

Expand Down Expand Up @@ -188,7 +189,7 @@ analyze_callee_regs_usage(dcontext_t *dcontext, callee_info_t *ci)

num_regparm = MIN(ci->num_args, NUM_REGPARM);
for (i = 0; i < num_regparm; i++) {
reg_id_t reg = regparms[i];
reg_id_t reg = d_r_regparms[i];
if (!ci->reg_used[reg - DR_REG_START_GPR]) {
LOG(THREAD, LOG_CLEANCALL, 2,
"CLEANCALL: callee " PFX " uses REG %s for arg passing\n", ci->start,
Expand Down Expand Up @@ -523,7 +524,7 @@ insert_inline_arg_setup(dcontext_t *dcontext, clean_call_info_t *cci, instrlist_
instr_t *where, opnd_t *args)
{
callee_info_t *ci = cci->callee_info;
reg_id_t regparm = regparms[0];
reg_id_t regparm = d_r_regparms[0];
opnd_t arg;

if (cci->num_args == 0)
Expand All @@ -532,7 +533,7 @@ insert_inline_arg_setup(dcontext_t *dcontext, clean_call_info_t *cci, instrlist_
/* If the arg is un-referenced, don't set it up. This is actually necessary
* for correctness because we will not have spilled regparm[0].
*/
if (!ci->reg_used[regparms[0] - DR_REG_START_GPR]) {
if (!ci->reg_used[d_r_regparms[0] - DR_REG_START_GPR]) {
LOG(THREAD, LOG_CLEANCALL, 2,
"CLEANCALL: callee " PFX " doesn't read arg, skipping arg setup.\n",
ci->start);
Expand Down
22 changes: 11 additions & 11 deletions core/arch/aarchxx/mangle.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* **********************************************************
* Copyright (c) 2014-2018 Google, Inc. All rights reserved.
* Copyright (c) 2014-2019 Google, Inc. All rights reserved.
* Copyright (c) 2016 ARM Limited. All rights reserved.
* **********************************************************/

Expand Down Expand Up @@ -883,7 +883,7 @@ insert_parameter_preparation(dcontext_t *dcontext, instrlist_t *ilist, instr_t *
}

/* Initialise regs[], which encodes the contents of parameter registers.
* A non-negative value x means regparms[x];
* A non-negative value x means d_r_regparms[x];
* -1 means an immediate integer;
* -2 means a non-parameter register.
*/
Expand All @@ -894,7 +894,7 @@ insert_parameter_preparation(dcontext_t *dcontext, instrlist_t *ilist, instr_t *
reg_id_t reg = opnd_get_reg(args[i]);
regs[i] = -2;
for (j = 0; j < NUM_REGPARM; j++) {
if (reg == regparms[j]) {
if (reg == d_r_regparms[j]) {
regs[i] = j;
break;
}
Expand All @@ -920,19 +920,19 @@ insert_parameter_preparation(dcontext_t *dcontext, instrlist_t *ilist, instr_t *
continue;
if (regs[i] == -1) {
insert_mov_immed_ptrsz(dcontext, opnd_get_immed_int(args[i]),
opnd_create_reg(regparms[i]), ilist, instr,
opnd_create_reg(d_r_regparms[i]), ilist, instr,
NULL, NULL);
} else if (regs[i] == -2 && opnd_get_reg(args[i]) == DR_REG_XSP) {
/* XXX: We could record which register has been set to the SP to
* avoid repeating this load if several arguments are set to SP.
*/
insert_get_mcontext_base(dcontext, ilist, instr, regparms[i]);
insert_get_mcontext_base(dcontext, ilist, instr, d_r_regparms[i]);
PRE(ilist, instr,
instr_create_restore_from_dc_via_reg(dcontext, regparms[i],
regparms[i], XSP_OFFSET));
instr_create_restore_from_dc_via_reg(
dcontext, d_r_regparms[i], d_r_regparms[i], XSP_OFFSET));
} else {
PRE(ilist, instr,
XINST_CREATE_move(dcontext, opnd_create_reg(regparms[i]),
XINST_CREATE_move(dcontext, opnd_create_reg(d_r_regparms[i]),
args[i]));
if (regs[i] != -2)
--usecount[regs[i]];
Expand All @@ -959,14 +959,14 @@ insert_parameter_preparation(dcontext_t *dcontext, instrlist_t *ilist, instr_t *
first = i;
PRE(ilist, instr,
XINST_CREATE_move(dcontext, opnd_create_reg(DR_REG_LR),
opnd_create_reg(regparms[i])));
opnd_create_reg(d_r_regparms[i])));
do {
tmp = regs[i];
ASSERT(0 <= tmp && tmp < num_regs);
PRE(ilist, instr,
XINST_CREATE_move(dcontext, opnd_create_reg(regparms[i]),
XINST_CREATE_move(dcontext, opnd_create_reg(d_r_regparms[i]),
tmp == first ? opnd_create_reg(DR_REG_LR)
: opnd_create_reg(regparms[tmp])));
: opnd_create_reg(d_r_regparms[tmp])));
regs[i] = i;
i = tmp;
} while (tmp != first);
Expand Down
6 changes: 3 additions & 3 deletions core/arch/arch.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* **********************************************************
* Copyright (c) 2010-2018 Google, Inc. All rights reserved.
* Copyright (c) 2010-2019 Google, Inc. All rights reserved.
* Copyright (c) 2000-2010 VMware, Inc. All rights reserved.
* **********************************************************/

Expand Down Expand Up @@ -425,8 +425,8 @@ void
clean_call_info_init(clean_call_info_t *cci, void *callee, bool save_fpstate,
uint num_args);
void
mangle(dcontext_t *dcontext, instrlist_t *ilist, uint *flags INOUT, bool mangle_calls,
bool record_translation);
d_r_mangle(dcontext_t *dcontext, instrlist_t *ilist, uint *flags INOUT, bool mangle_calls,
bool record_translation);
bool
parameters_stack_padded(void);
/* Inserts a complete call to callee with the passed-in arguments */
Expand Down
8 changes: 4 additions & 4 deletions core/arch/arch_exports.h
Original file line number Diff line number Diff line change
Expand Up @@ -1225,8 +1225,8 @@ get_app_sysenter_addr(void);

/* in [x86/arm].asm */
/* Calls the specified function 'func' after switching to the stack 'stack'. If we're
* currently on the initstack 'mutex_to_free' should be passed so we release the
* initstack lock. The supplied 'func_arg' will be passed as an argument to 'func'.
* currently on the d_r_initstack, 'mutex_to_free' should be passed so we release the
* initstack_mutex. The supplied 'func_arg' will be passed as an argument to 'func'.
* If 'func' returns then 'return_on_return' is checked. If set we swap back stacks and
* return to the caller. If not set then it's assumed that func wasn't supposed to
* return and we go to an error routine unexpected_return() below.
Expand All @@ -1247,8 +1247,8 @@ go_native(dcontext_t *dcontext);

/* Calls dynamo_exit_process if exitproc is true, else calls dynamo_exit_thread.
* Uses the current dstack, but instructs the cleanup routines not to
* de-allocate it, does a custom de-allocate after swapping to initstack (don't
* want to use initstack the whole time, that's too long to hold the mutex).
* de-allocate it, does a custom de-allocate after swapping to d_r_initstack (don't
* want to use d_r_initstack the whole time, that's too long to hold the mutex).
* Then calls system call sysnum with parameter base param_base, which is presumed
* to be either NtTerminateThread or NtTerminateProcess or exit.
*
Expand Down
14 changes: 7 additions & 7 deletions core/arch/arm/arm.asm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* **********************************************************
* Copyright (c) 2014-2016 Google, Inc. All rights reserved.
* Copyright (c) 2014-2019 Google, Inc. All rights reserved.
* ********************************************************** */

/*
Expand Down Expand Up @@ -47,7 +47,7 @@ DECL_EXTERN(relocate_dynamorio)
DECL_EXTERN(privload_early_inject)

DECL_EXTERN(exiting_thread_count)
DECL_EXTERN(initstack)
DECL_EXTERN(d_r_initstack)
DECL_EXTERN(initstack_mutex)

#define RESTORE_FROM_DCONTEXT_VIA_REG(reg,offs,dest) ldr dest, PTRSZ [reg, POUND (offs)]
Expand Down Expand Up @@ -279,7 +279,7 @@ cat_done_saving_dstack:
cat_thread_only:
CALLC0(GLOBAL_REF(dynamo_thread_exit))
cat_no_thread:
/* switch to initstack for cleanup of dstack */
/* switch to d_r_initstack for cleanup of dstack */
/* we use r6, r7, and r8 here so that atomic_swap doesn't clobber them */
mov REG_R6, #1
ldr REG_R8, .Lgot1
Expand All @@ -300,12 +300,12 @@ cat_have_lock:
/* swap stacks */
ldr REG_R2, .Lgot2
add REG_R2, REG_R2, pc
ldr REG_R3, .Linitstack
ldr REG_R3, .Ld_r_initstack
.LPIC2: ldr REG_R3, [REG_R3, REG_R2]
ldr sp, [REG_R3]
/* free dstack and call the EXIT_DR_HOOK */
CALLC1(GLOBAL_REF(dynamo_thread_stack_free_and_exit), REG_R4) /* pass dstack */
/* give up initstack mutex */
/* give up initstack_mutex */
ldr REG_R2, .Lgot3
add REG_R2, REG_R2, pc
ldr REG_R3, .Linitstack_mutex
Expand Down Expand Up @@ -338,8 +338,8 @@ cat_have_lock:
.long _GLOBAL_OFFSET_TABLE_-.LPIC4
.Lexiting_thread_count:
.word exiting_thread_count(GOT)
.Linitstack:
.word initstack(GOT)
.Ld_r_initstack:
.word d_r_initstack(GOT)
.Linitstack_mutex:
.word initstack_mutex(GOT)
#endif /* NOT_DYNAMORIO_CORE_PROPER */
Expand Down
10 changes: 5 additions & 5 deletions core/arch/clean_call_opt_shared.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* **********************************************************
* Copyright (c) 2010-2019 Google, Inc. All rights reserved.
* Copyright (c) 2016 ARM Limited. All rights reserved.
* Copyright (c) 2010-2014 Google, Inc. All rights reserved.
* Copyright (c) 2010 Massachusetts Institute of Technology All rights reserved.
* Copyright (c) 2000-2010 VMware, Inc. All rights reserved.
* Copyright (c) 2003-2007 Determina Corp.
Expand Down Expand Up @@ -541,12 +541,12 @@ analyze_clean_call_regs(dcontext_t *dcontext, clean_call_info_t *cci)
*/
num_regparm = cci->num_args < NUM_REGPARM ? cci->num_args : NUM_REGPARM;
for (i = 0; i < num_regparm; i++) {
if (cci->reg_skip[regparms[i] - DR_REG_START_GPR]) {
if (cci->reg_skip[d_r_regparms[i] - DR_REG_START_GPR]) {
LOG(THREAD, LOG_CLEANCALL, 3,
"CLEANCALL: if inserting clean call " PFX
", cannot skip saving reg %s due to param passing.\n",
info->start, reg_names[regparms[i]]);
cci->reg_skip[regparms[i] - DR_REG_START_GPR] = false;
info->start, reg_names[d_r_regparms[i]]);
cci->reg_skip[d_r_regparms[i] - DR_REG_START_GPR] = false;
cci->num_regs_skip--;
/* We cannot call callee_info_reserve_slot for reserving slot
* on inlining the callee here, because we are in clean call
Expand Down Expand Up @@ -576,7 +576,7 @@ analyze_clean_call_args(dcontext_t *dcontext, clean_call_info_t *cci, opnd_t *ar
if (opnd_is_reg(args[i]))
cci->save_all_regs = true;
for (j = 0; j < num_regparm; j++) {
if (opnd_uses_reg(args[i], regparms[j]))
if (opnd_uses_reg(args[i], d_r_regparms[j]))
cci->save_all_regs = true;
}
}
Expand Down
6 changes: 3 additions & 3 deletions core/arch/disassemble_shared.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* **********************************************************
* Copyright (c) 2011-2018 Google, Inc. All rights reserved.
* Copyright (c) 2011-2019 Google, Inc. All rights reserved.
* Copyright (c) 2001-2009 VMware, Inc. All rights reserved.
* **********************************************************/

Expand Down Expand Up @@ -1253,7 +1253,7 @@ common_disassemble_fragment(dcontext_t *dcontext, fragment_t *f_in, file_t outfi
if (dynamo_options.profile_times && (f->flags & FRAG_IS_TRACE) != 0) {
int sz = profile_call_size();
profile_end = pc + sz;
if (stats->loglevel < 3) {
if (d_r_stats->loglevel < 3) {
/* don't print profile stuff to save space */
print_file(outfile, " " PFX "..." PFX " = profile code\n", pc,
(pc + sz - 1));
Expand Down Expand Up @@ -1364,7 +1364,7 @@ common_disassemble_fragment(dcontext_t *dcontext, fragment_t *f_in, file_t outfi
void
disassemble_fragment(dcontext_t *dcontext, fragment_t *f, bool just_header)
{
if ((stats->logmask & LOG_EMIT) != 0) {
if ((d_r_stats->logmask & LOG_EMIT) != 0) {
common_disassemble_fragment(dcontext, f, THREAD, true, !just_header);
if (!just_header)
LOG(THREAD, LOG_EMIT, 1, "\n");
Expand Down
4 changes: 2 additions & 2 deletions core/arch/instr.h
Original file line number Diff line number Diff line change
Expand Up @@ -2387,10 +2387,10 @@ opnd_t
instr_get_src_mem_access(instr_t *instr);

void
loginst(dcontext_t *dcontext, uint level, instr_t *instr, const char *string);
d_r_loginst(dcontext_t *dcontext, uint level, instr_t *instr, const char *string);

void
logopnd(dcontext_t *dcontext, uint level, opnd_t opnd, const char *string);
d_r_logopnd(dcontext_t *dcontext, uint level, opnd_t opnd, const char *string);

DR_API
/**
Expand Down
Loading

0 comments on commit feea1d6

Please sign in to comment.