mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-15 12:54:27 +00:00
- Make sure to set an error code when trying to obtain a data descriptor for
a section of type SHT_NULL. - Update the man page to reflect the fact that elf_getdata() and elf_rawdata() may return with an error of ELF_E_SECTION. PR: bin/175491 Approved by: emaste (co-mentor) MFC after: 1 week
This commit is contained in:
parent
bab63de286
commit
9be24c38b8
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=246978
|
@ -78,8 +78,10 @@ elf_getdata(Elf_Scn *s, Elf_Data *d)
|
||||||
sh_align = s->s_shdr.s_shdr64.sh_addralign;
|
sh_align = s->s_shdr.s_shdr64.sh_addralign;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sh_type == SHT_NULL)
|
if (sh_type == SHT_NULL) {
|
||||||
|
LIBELF_SET_ERROR(SECTION, 0);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
if ((elftype = _libelf_xlate_shtype(sh_type)) < ELF_T_FIRST ||
|
if ((elftype = _libelf_xlate_shtype(sh_type)) < ELF_T_FIRST ||
|
||||||
elftype > ELF_T_LAST || (sh_type != SHT_NOBITS &&
|
elftype > ELF_T_LAST || (sh_type != SHT_NOBITS &&
|
||||||
|
@ -219,8 +221,10 @@ elf_rawdata(Elf_Scn *s, Elf_Data *d)
|
||||||
sh_align = s->s_shdr.s_shdr64.sh_addralign;
|
sh_align = s->s_shdr.s_shdr64.sh_addralign;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sh_type == SHT_NULL)
|
if (sh_type == SHT_NULL) {
|
||||||
|
LIBELF_SET_ERROR(SECTION, 0);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
if ((d = _libelf_allocate_data(s)) == NULL)
|
if ((d = _libelf_allocate_data(s)) == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
.\"
|
.\"
|
||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd January 26, 2011
|
.Dd February 18, 2013
|
||||||
.Dt ELF_GETDATA 3
|
.Dt ELF_GETDATA 3
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
|
@ -186,6 +186,23 @@ was not associated with section descriptor
|
||||||
.Ar scn .
|
.Ar scn .
|
||||||
.It Bq Er ELF_E_RESOURCE
|
.It Bq Er ELF_E_RESOURCE
|
||||||
An out of memory condition was detected.
|
An out of memory condition was detected.
|
||||||
|
.It Bq Er ELF_E_SECTION
|
||||||
|
Section
|
||||||
|
.Ar scn
|
||||||
|
had type
|
||||||
|
.Dv SHT_NULL .
|
||||||
|
.It Bq Er ELF_E_SECTION
|
||||||
|
The type of the section
|
||||||
|
.Ar scn
|
||||||
|
was not recognized by the library.
|
||||||
|
.It Bq Er ELF_E_SECTION
|
||||||
|
The size of the section
|
||||||
|
.Ar scn
|
||||||
|
is not a multiple of the file size for its section type.
|
||||||
|
.It Bq Er ELF_E_SECTION
|
||||||
|
The file offset for section
|
||||||
|
.Ar scn
|
||||||
|
is incorrect.
|
||||||
.El
|
.El
|
||||||
.Sh SEE ALSO
|
.Sh SEE ALSO
|
||||||
.Xr elf 3 ,
|
.Xr elf 3 ,
|
||||||
|
|
Loading…
Reference in a new issue