kern_ctf.c: Don't print out warning messages unconditionally

The kernel CTF loading routines print various warnings when attempting
to load CTF data from an ELF file. After the changes in c21bc6f3c2
those warnings are unnecessarily printed for each kernel module
that was compiled without CTF data.

The kernel linker already uses the bootverbose flag to conditionally
print CTF loading errors. This patch alters kern_ctf.c
routines to do the same.

Reported by:	Alexander@leidinger.net
Approved by:	markj (mentor)
Fixes: c21bc6f3c2 ("ddb: Add CTF-based pretty printing")
This commit is contained in:
Bojan Novković 2024-03-29 20:17:19 +01:00
parent 2ae32f1f8f
commit bdc903460b

View file

@ -144,9 +144,12 @@ link_elf_ctf_get(linker_file_t lf, linker_ctf_t *lc)
* .SUNW_ctf section containing the CTF data.
*/
if (hdr->e_shstrndx == 0 || shdr[hdr->e_shstrndx].sh_type != SHT_STRTAB) {
printf("%s(%d): module %s e_shstrndx is %d, sh_type is %d\n",
__func__, __LINE__, lf->pathname, hdr->e_shstrndx,
shdr[hdr->e_shstrndx].sh_type);
if (bootverbose) {
printf(
"%s(%d): module %s e_shstrndx is %d, sh_type is %d\n",
__func__, __LINE__, lf->pathname, hdr->e_shstrndx,
shdr[hdr->e_shstrndx].sh_type);
}
error = EFTYPE;
goto out;
}
@ -167,8 +170,10 @@ link_elf_ctf_get(linker_file_t lf, linker_ctf_t *lc)
/* Check if the CTF section wasn't found. */
if (i >= hdr->e_shnum) {
printf("%s(%d): module %s has no .SUNW_ctf section\n",
__func__, __LINE__, lf->pathname);
if (bootverbose) {
printf("%s(%d): module %s has no .SUNW_ctf section\n",
__func__, __LINE__, lf->pathname);
}
error = EFTYPE;
goto out;
}
@ -181,17 +186,21 @@ link_elf_ctf_get(linker_file_t lf, linker_ctf_t *lc)
/* Check the CTF magic number. */
if (cth.cth_magic != CTF_MAGIC) {
printf("%s(%d): module %s has invalid format\n",
__func__, __LINE__, lf->pathname);
if (bootverbose) {
printf("%s(%d): module %s has invalid format\n",
__func__, __LINE__, lf->pathname);
}
error = EFTYPE;
goto out;
}
if (cth.cth_version != CTF_VERSION_2 &&
cth.cth_version != CTF_VERSION_3) {
printf(
"%s(%d): module %s CTF format has unsupported version %d\n",
__func__, __LINE__, lf->pathname, cth.cth_version);
if (bootverbose) {
printf(
"%s(%d): module %s CTF format has unsupported version %d\n",
__func__, __LINE__, lf->pathname, cth.cth_version);
}
error = EFTYPE;
goto out;
}
@ -250,8 +259,10 @@ link_elf_ctf_get(linker_file_t lf, linker_ctf_t *lc)
ret = uncompress(ctftab + sizeof(cth), &destlen,
raw + sizeof(cth), shdr[i].sh_size - sizeof(cth));
if (ret != Z_OK) {
printf("%s(%d): zlib uncompress returned %d\n",
__func__, __LINE__, ret);
if (bootverbose) {
printf("%s(%d): zlib uncompress returned %d\n",
__func__, __LINE__, ret);
}
error = EIO;
goto out;
}