summaryrefslogtreecommitdiffstats
path: root/libdwfl/linux-kernel-modules.c
diff options
context:
space:
mode:
authorRoland McGrath <[email protected]>2005-11-21 23:40:54 +0000
committerRoland McGrath <[email protected]>2005-11-21 23:40:54 +0000
commit2e53b9950e52c08cc61c30755e58523860619b8a (patch)
tree97ccd150226210bb072d812ca7d6e3dbc6dad8e6 /libdwfl/linux-kernel-modules.c
parentb6405ca24bf950aa9baaac0b9e949963a6569e08 (diff)
2005-11-21 Roland McGrath <[email protected]>
* linux-kernel-modules.c (dwfl_linux_kernel_module_section_address): Don't leak malloc'd file name. If a /sys/.../sections file is missing and starts with ".init", try the variant with "_init" too; catches PPC64 kernel braindamage.
Diffstat (limited to 'libdwfl/linux-kernel-modules.c')
-rw-r--r--libdwfl/linux-kernel-modules.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/libdwfl/linux-kernel-modules.c b/libdwfl/linux-kernel-modules.c
index c219c330..39a055f6 100644
--- a/libdwfl/linux-kernel-modules.c
+++ b/libdwfl/linux-kernel-modules.c
@@ -373,6 +373,8 @@ dwfl_linux_kernel_module_section_address
return ENOMEM;
FILE *f = fopen (sysfile, "r");
+ free (sysfile);
+
if (f == NULL)
{
if (errno == ENOENT)
@@ -392,11 +394,29 @@ dwfl_linux_kernel_module_section_address
*addr = 0;
return DWARF_CB_OK;
}
+
+ /* The goofy PPC64 module_frob_arch_sections function tweaks
+ the section names as a way to control other kernel code's
+ behavior, and this cruft leaks out into the /sys information.
+ The file name for ".init*" may actually look like "_init*". */
+
+ if (!strncmp (secname, ".init", 5))
+ {
+ sysfile = NULL;
+ asprintf (&sysfile, SECADDRFMT "%s", modname, "_", &secname[1]);
+ if (sysfile == NULL)
+ return ENOMEM;
+ f = fopen (sysfile, "r");
+ free (sysfile);
+ if (f != NULL)
+ goto ok;
+ }
}
return DWARF_CB_ABORT;
}
+ ok:
(void) __fsetlocking (f, FSETLOCKING_BYCALLER);
int result = (fscanf (f, "%" PRIx64 "\n", addr) == 1 ? 0