Coverage Report

Created: 2025-11-27 06:22

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
1.27M
#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
637k
{
19
20
637k
  ElfW2(LIBELFBITS,Shdr) *shdr = ADD_ROUTINE_PREFIX(elfw2(LIBELFBITS, ADD_ROUTINE_SUFFIX(getshdr)))(scn);
21
22
637k
  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
637k
  if ((shdr->sh_flags & SHF_ALLOC) != 0)
28
3.11k
    {
29
3.11k
      __libelf_seterrno (ELF_E_INVALID_SECTION_FLAGS);
30
3.11k
      return NULL;
31
3.11k
    }
32
33
633k
  if (shdr->sh_type == SHT_NULL
34
633k
      || shdr->sh_type == SHT_NOBITS)
35
0
    {
36
0
      __libelf_seterrno (ELF_E_INVALID_SECTION_TYPE);
37
0
      return NULL;
38
0
    }
39
40
633k
  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
633k
  Elf_Data *d  = ADD_ROUTINE_PREFIX(ADD_ROUTINE_SUFFIX(elf_getdata)) (scn, NULL);
49
633k
  if (d == NULL)
50
339k
    return NULL;
51
52
294k
  if (d->d_size < sizeof (ElfW2(LIBELFBITS,Chdr)) || d->d_buf == NULL)
53
25.3k
    {
54
25.3k
      __libelf_seterrno (ELF_E_INVALID_DATA);
55
25.3k
      return NULL;
56
25.3k
    }
57
58
269k
  return (ElfW2(LIBELFBITS,Chdr) *) d->d_buf;
59
294k
}
Unexecuted instantiation: __elf32_getchdr_wrlock
elf32_getchdr
Line
Count
Source
18
552k
{
19
20
552k
  ElfW2(LIBELFBITS,Shdr) *shdr = ADD_ROUTINE_PREFIX(elfw2(LIBELFBITS, ADD_ROUTINE_SUFFIX(getshdr)))(scn);
21
22
552k
  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
552k
  if ((shdr->sh_flags & SHF_ALLOC) != 0)
28
2.60k
    {
29
2.60k
      __libelf_seterrno (ELF_E_INVALID_SECTION_FLAGS);
30
2.60k
      return NULL;
31
2.60k
    }
32
33
549k
  if (shdr->sh_type == SHT_NULL
34
549k
      || shdr->sh_type == SHT_NOBITS)
35
0
    {
36
0
      __libelf_seterrno (ELF_E_INVALID_SECTION_TYPE);
37
0
      return NULL;
38
0
    }
39
40
549k
  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
549k
  Elf_Data *d  = ADD_ROUTINE_PREFIX(ADD_ROUTINE_SUFFIX(elf_getdata)) (scn, NULL);
49
549k
  if (d == NULL)
50
305k
    return NULL;
51
52
243k
  if (d->d_size < sizeof (ElfW2(LIBELFBITS,Chdr)) || d->d_buf == NULL)
53
23.0k
    {
54
23.0k
      __libelf_seterrno (ELF_E_INVALID_DATA);
55
23.0k
      return NULL;
56
23.0k
    }
57
58
220k
  return (ElfW2(LIBELFBITS,Chdr) *) d->d_buf;
59
243k
}
Unexecuted instantiation: __elf64_getchdr_wrlock
elf64_getchdr
Line
Count
Source
18
84.9k
{
19
20
84.9k
  ElfW2(LIBELFBITS,Shdr) *shdr = ADD_ROUTINE_PREFIX(elfw2(LIBELFBITS, ADD_ROUTINE_SUFFIX(getshdr)))(scn);
21
22
84.9k
  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
84.9k
  if ((shdr->sh_flags & SHF_ALLOC) != 0)
28
506
    {
29
506
      __libelf_seterrno (ELF_E_INVALID_SECTION_FLAGS);
30
506
      return NULL;
31
506
    }
32
33
84.4k
  if (shdr->sh_type == SHT_NULL
34
84.4k
      || shdr->sh_type == SHT_NOBITS)
35
0
    {
36
0
      __libelf_seterrno (ELF_E_INVALID_SECTION_TYPE);
37
0
      return NULL;
38
0
    }
39
40
84.4k
  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
84.4k
  Elf_Data *d  = ADD_ROUTINE_PREFIX(ADD_ROUTINE_SUFFIX(elf_getdata)) (scn, NULL);
49
84.4k
  if (d == NULL)
50
33.5k
    return NULL;
51
52
50.9k
  if (d->d_size < sizeof (ElfW2(LIBELFBITS,Chdr)) || d->d_buf == NULL)
53
2.30k
    {
54
2.30k
      __libelf_seterrno (ELF_E_INVALID_DATA);
55
2.30k
      return NULL;
56
2.30k
    }
57
58
48.6k
  return (ElfW2(LIBELFBITS,Chdr) *) d->d_buf;
59
50.9k
}
60
#undef INTERNAL
61
#undef ELF_WRLOCK_HELD