aboutsummaryrefslogtreecommitdiff
path: root/lib/libelf/elf_getdata.3
diff options
context:
space:
mode:
authorKai Wang <kaiw@FreeBSD.org>2010-07-21 08:54:46 +0000
committerKai Wang <kaiw@FreeBSD.org>2010-07-21 08:54:46 +0000
commit7ee5b008fbbb4c56773ee3c4536903d758d94bea (patch)
tree9f252b8a2b18f7aca5a209ccd3e4417297b74185 /lib/libelf/elf_getdata.3
parent8b18f12fc6fee398507217513e9ae37615757e44 (diff)
downloadsrc-7ee5b008fbbb4c56773ee3c4536903d758d94bea.tar.gz
src-7ee5b008fbbb4c56773ee3c4536903d758d94bea.zip
- Correctly handle sections of type SHT_NOBITS. For these sections:
- elf_getdata() and elf_rawdata() should return an "Elf_Data" structure that has its "d_buf" member set to NULL and "d_size" member set to the nominal 'size' of the section. [1] - Update the manual page for these functions. - Fix a memory leak in an error handling path inside elf_getdata(). - Use _libelf_allocate_data() in elf_newdata() for consistency. Obtained from: elftoolchain MFC after: 1 month
Notes
Notes: svn path=/head/; revision=210324
Diffstat (limited to 'lib/libelf/elf_getdata.3')
-rw-r--r--lib/libelf/elf_getdata.328
1 files changed, 27 insertions, 1 deletions
diff --git a/lib/libelf/elf_getdata.3 b/lib/libelf/elf_getdata.3
index 10f37639563b..565c77c8a02f 100644
--- a/lib/libelf/elf_getdata.3
+++ b/lib/libelf/elf_getdata.3
@@ -1,4 +1,4 @@
-.\" Copyright (c) 2006 Joseph Koshy. All rights reserved.
+.\" Copyright (c) 2006,2008 Joseph Koshy. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
@@ -142,6 +142,32 @@ always returns
.Vt Elf_Data
structures of type
.Dv ELF_T_BYTE .
+.Ss Special handling of SHT_NOBITS sections
+For sections of type
+.Dv SHT_NOBITS ,
+the functions
+.Fn elf_getdata
+and
+.Fn elf_rawdata
+return a pointer to a valid
+.Vt Elf_Data
+structure that has its
+.Va d_buf
+member set to NULL and its
+.Va d_size
+member set to the size of the section.
+.Pp
+If an application wishes to create a section of type
+.Dv SHT_NOBITS ,
+it should add a data buffer to the section using function
+.Fn elf_newdata .
+It should then set the
+.Va d_buf
+and
+.Va d_size
+members of the returned
+.Vt Elf_Data
+structure to NULL and the desired size of the section respectively.
.Sh RETURN VALUES
These functions return a valid pointer to a data descriptor if successful, or
NULL if an error occurs.