From 687f10754f1b806e8c4ad86b48f93ac485293fb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vivek=20Das=C2=A0Mohapatra?= <vivek@collabora.co.uk> Date: Wed, 24 May 2017 20:29:05 +0100 Subject: [PATCH] capsule-dlmopen.c: when debugging WRAPPERS turn on extra debug for ELF The code path that installs wrappers inside the capsule is the same as the one that scribbles capsule functions out into the rest of the application - however if we don't want to turn on noisy debug in the ELF handling paths all the time - so we cheat and turn it on around the ELF munging call from the wrap function only if DEBUG_WRAPPERS is already in the flags. --- capsule/capsule-dlmopen.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/capsule/capsule-dlmopen.c b/capsule/capsule-dlmopen.c index aade4bc42..e800ae13a 100644 --- a/capsule/capsule-dlmopen.c +++ b/capsule/capsule-dlmopen.c @@ -1353,6 +1353,12 @@ wrap (const char *name, if( mmap_entry_should_be_writable( &rdata.mmap_info[i] ) ) add_mmap_protection( &rdata.mmap_info[i], PROT_WRITE ); + // if we're debugging wrapper installation in detail we + // will end up in a path that's normally only DEBUG_ELF + // debugged: + if( debug_flags & DEBUG_WRAPPERS ) + debug_flags = debug_flags | DEBUG_ELF; + // install any required wrappers inside the capsule: process_pt_dynamic( (void *)start, // offset from phdr to dyn section size, // fake size value (max possible value) @@ -1361,6 +1367,9 @@ wrap (const char *name, process_dt_rel, &rdata ); + // put the debug flags back in case we changed them + debug_flags = rdata.debug; + // put the mmap()/mprotect() permissions back the way they were: for( int i = 0; rdata.mmap_info[i].start != MAP_FAILED; i++ ) if( mmap_entry_should_be_writable( &rdata.mmap_info[i] ) ) -- GitLab