From: Roland McGrath Date: Mon, 21 Jun 2010 11:41:03 +0000 (-0700) Subject: Early close for mapped files in libdwfl. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b29d7ff6ac4025ecd59e01bdb908c6921d256303;p=thirdparty%2Felfutils.git Early close for mapped files in libdwfl. --- diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index 92be9488a..e71e33d67 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,5 +1,7 @@ 2010-06-21 Roland McGrath + * open.c (__libdw_open_file): Close the fd when it's already mapped. + * dwfl_module_getsrc_file.: Update for Dwarf_Line member change. * dwfl_lineinfo.c: Likewise. Use dwarf_lineaddr. diff --git a/libdwfl/open.c b/libdwfl/open.c index 397af358f..063dece84 100644 --- a/libdwfl/open.c +++ b/libdwfl/open.c @@ -190,9 +190,13 @@ __libdw_open_file (int *fdp, Elf **elfp, bool close_on_fail, bool archive_ok) { elf_end (elf); elf = NULL; + close_fd = close_on_fail; } - if (error == DWFL_E_NOERROR ? close_fd : close_on_fail) + if (*fdp != -1 + && (close_fd || (close_on_fail + && elf->map_address != NULL + && elf_cntl (elf, ELF_C_FDREAD) == 0))) { close (*fdp); *fdp = -1;