Coverage Report

Created: 2025-11-27 06:21

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/elfutils/libelf/elf32_getchdr.h
Line
Count
Source
1
#undef ADD_ROUTINE_PREFIX
2
#undef ADD_ROUTINE_SUFFIX
3
4
#if ELF_WRLOCK_HELD
5
0
#define CONCAT(x,y) x##y
6
0
#define ADD_ROUTINE_PREFIX(y) CONCAT(__,y)
7
#define ADD_ROUTINE_SUFFIX(x) x ## _wrlock
8
#define INTERNAL internal_function
9
#else
10
0
#define ADD_ROUTINE_PREFIX(y) y
11
#define ADD_ROUTINE_SUFFIX(x) x
12
#define INTERNAL
13
#endif
14
15
ElfW2(LIBELFBITS,Chdr) *
16
INTERNAL
17
ADD_ROUTINE_PREFIX(elfw2(LIBELFBITS, ADD_ROUTINE_SUFFIX(getchdr))) (Elf_Scn *scn)
18
0
{
19
20
0
  ElfW2(LIBELFBITS,Shdr) *shdr = ADD_ROUTINE_PREFIX(elfw2(LIBELFBITS, ADD_ROUTINE_SUFFIX(getshdr)))(scn);
21
22
0
  if (shdr == NULL)
23
0
    return NULL;
24
25
  /* Must have SHF_COMPRESSED flag set.  Allocated or no bits sections
26
     can never be compressed.  */
27
0
  if ((shdr->sh_flags & SHF_ALLOC) != 0)
28
0
    {
29
0
      __libelf_seterrno (ELF_E_INVALID_SECTION_FLAGS);
30
0
      return NULL;
31
0
    }
32
33
0
  if (shdr->sh_type == SHT_NULL
34
0
      || shdr->sh_type == SHT_NOBITS)
35
0
    {
36
0
      __libelf_seterrno (ELF_E_INVALID_SECTION_TYPE);
37
0
      return NULL;
38
0
    }
39
40
0
  if ((shdr->sh_flags & SHF_COMPRESSED) == 0)
41
0
    {
42
0
      __libelf_seterrno (ELF_E_NOT_COMPRESSED);
43
0
      return NULL;
44
0
    }
45
46
  /* This makes sure the data is in the correct format, so we don't
47
     need to swap fields. */
48
0
  Elf_Data *d  = ADD_ROUTINE_PREFIX(ADD_ROUTINE_SUFFIX(elf_getdata)) (scn, NULL);
49
0
  if (d == NULL)
50
0
    return NULL;
51
52
0
  if (d->d_size < sizeof (ElfW2(LIBELFBITS,Chdr)) || d->d_buf == NULL)
53
0
    {
54
0
      __libelf_seterrno (ELF_E_INVALID_DATA);
55
0
      return NULL;
56
0
    }
57
58
0
  return (ElfW2(LIBELFBITS,Chdr) *) d->d_buf;
59
0
}
Unexecuted instantiation: __elf32_getchdr_wrlock
Unexecuted instantiation: elf32_getchdr
Unexecuted instantiation: __elf64_getchdr_wrlock
Unexecuted instantiation: elf64_getchdr
60
#undef INTERNAL
61
#undef ELF_WRLOCK_HELD