On Wed, 10 Sep 2014 20:56:48 +0200, Mark Wielaard wrote:
> I don't think it is very helpful or productive to refuse to have a
> technical opinion on a fair question about a code change you are
> proposing.
By ": 1" I give a promise to compiler I will use only its single bit.
Smart compiler with -fwhole-program, -flto etc. could make it 'unsigned char'
when the struct is not externally visible and therefore ABI-constrained.
But I see in real world the -O2 x86_64 'bool:1' code is much more horrible
compared to plain 'bool' than I expected, so when we already discuss it I have
changed it to 'bool'.
400406: 88 44 24 e9 mov %dl,-0x17(%rsp)
vs.
400400: 0f b6 44 24 e8 movzbl -0x18(%rsp),%eax
40040b: c1 e2 03 shl $0x3,%edx
40040e: 83 e0 f7 and $0xfffffff7,%eax
400411: 09 d0 or %edx,%eax
400413: 88 44 24 e8 mov %al,-0x18(%rsp)
Thanks,
Jan
--- Begin Message ---
Next patch will find module names from NT_FILE note so that main executable
will no longer necessarily have the name "[exe]" or "[pie]".
-e|--executable still should be able to override such module.
libdwfl/
2014-09-10 Jan Kratochvil <jan.kratoch...@redhat.com>
* dwfl_build_id_find_elf.c (dwfl_build_id_find_elf): Use IS_EXECUTABLE.
* dwfl_segment_report_module.c (dwfl_segment_report_module): Set
IS_EXECUTABLE.
* libdwflP.h (struct Dwfl_Module): New field is_executable.
Signed-off-by: Jan Kratochvil <jan.kratoch...@redhat.com>
---
libdwfl/ChangeLog | 7 +++++++
libdwfl/dwfl_build_id_find_elf.c | 7 +++----
libdwfl/dwfl_segment_report_module.c | 6 ++++++
libdwfl/libdwflP.h | 1 +
4 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index 3de772e..7425d5c 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,10 @@
+2014-09-10 Jan Kratochvil <jan.kratoch...@redhat.com>
+
+ * dwfl_build_id_find_elf.c (dwfl_build_id_find_elf): Use IS_EXECUTABLE.
+ * dwfl_segment_report_module.c (dwfl_segment_report_module): Set
+ IS_EXECUTABLE.
+ * libdwflP.h (struct Dwfl_Module): New field is_executable.
+
2014-08-28 Jan Kratochvil <jan.kratoch...@redhat.com>
* dwfl_module_getdwarf.c (find_offsets): Add parameter main_bias, use
diff --git a/libdwfl/dwfl_build_id_find_elf.c b/libdwfl/dwfl_build_id_find_elf.c
index 1555008..062aad1 100644
--- a/libdwfl/dwfl_build_id_find_elf.c
+++ b/libdwfl/dwfl_build_id_find_elf.c
@@ -124,13 +124,12 @@ dwfl_build_id_find_elf (Dwfl_Module *mod,
char **file_name, Elf **elfp)
{
*elfp = NULL;
- if (modname != NULL && mod->dwfl->executable_for_core != NULL
- && (strcmp (modname, "[exe]") == 0 || strcmp (modname, "[pie]") == 0))
+ if (mod->is_executable && mod->dwfl->executable_for_core != NULL)
{
/* When dwfl_core_file_report was called with a non-NULL executable file
name this callback will replace the Dwfl_Module main.name with the
- recorded executable file when the modname is [exe] or [pie] (which
- then triggers opening and reporting of the executable). */
+ recorded executable file when MOD was identified as main executable
+ (which then triggers opening and reporting of the executable). */
int fd = open64 (mod->dwfl->executable_for_core, O_RDONLY);
if (fd >= 0)
{
diff --git a/libdwfl/dwfl_segment_report_module.c
b/libdwfl/dwfl_segment_report_module.c
index dfecb51..3393b08 100644
--- a/libdwfl/dwfl_segment_report_module.c
+++ b/libdwfl/dwfl_segment_report_module.c
@@ -646,6 +646,12 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const
char *name,
Dwfl_Module *mod = INTUSE(dwfl_report_module) (dwfl, name,
module_start, module_end);
+
+ // !execlike && ET_EXEC is PIE.
+ // execlike && !ET_EXEC is a static executable.
+ if (mod != NULL && (execlike || ehdr.e32.e_type == ET_EXEC))
+ mod->is_executable = true;
+
if (likely (mod != NULL) && build_id != NULL
&& unlikely (INTUSE(dwfl_module_report_build_id) (mod,
build_id,
diff --git a/libdwfl/libdwflP.h b/libdwfl/libdwflP.h
index 30c0f8a..735b920 100644
--- a/libdwfl/libdwflP.h
+++ b/libdwfl/libdwflP.h
@@ -211,6 +211,7 @@ struct Dwfl_Module
int segment; /* Index of first segment table entry. */
bool gc; /* Mark/sweep flag. */
+ bool is_executable; /* Use Dwfl::executable_for_core? */
};
/* This holds information common for all the threads/tasks/TIDs of one process
--
1.9.3
--- End Message ---