Skip to content

Commit

Permalink
Update ELF Tool Chain to upstream r3769
Browse files Browse the repository at this point in the history
This contains many small bugfixes and documentation improvements.

Sponsored by:	The FreeBSD Foundation
  • Loading branch information
emaste committed Dec 5, 2019
2 parents 2e26edd + 061ef1f commit ca86244
Show file tree
Hide file tree
Showing 71 changed files with 555 additions and 289 deletions.
22 changes: 22 additions & 0 deletions contrib/elftoolchain/.cirrus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
freebsd_11_task:
freebsd_instance:
image: freebsd-11-2-release-amd64
install_script: pkg install -y git py27-yaml
script:
- fetch http://tetworks.opengroup.org/downloads/38/software/Sources/3.8/tet3.8-src.tar.gz
- tar -x -C test/tet -f tet3.8-src.tar.gz
- make

debian_stable_task:
container:
image: debian:stable
setup_script:
- apt-get update
- apt-get install -y
binutils bison bmake curl flex g++ gcc git
libarchive-dev libbsd-dev libc6-dev libexpat1-dev lsb-release
m4 perl python-yaml sharutils zlib1g-dev
script:
- curl -O http://tetworks.opengroup.org/downloads/38/software/Sources/3.8/tet3.8-src.tar.gz
- tar -x -C test/tet -z -f tet3.8-src.tar.gz
- bmake
10 changes: 5 additions & 5 deletions contrib/elftoolchain/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ The project uses subversion_ for its version control system.
The subversion branch for the current set of sources may be accessed
at the following URL::

https://elftoolchain.svn.sourceforge.net/svnroot/elftoolchain/trunk
https://sourceforge.net/p/elftoolchain/code/HEAD/tree/trunk/

The project's source tree may be checked out from its repository by
using the ``svn checkout`` command::

% svn checkout https://elftoolchain.svn.sourceforge.net/svnroot/elftoolchain/trunk
% svn checkout https://svn.code.sf.net/p/elftoolchain/code/trunk

Checked-out sources may be kept upto-date by running ``svn update``
inside the source directory::
Expand Down Expand Up @@ -105,10 +105,10 @@ The project's developers may be contacted using the mailing list:
Reporting Bugs
--------------

Please use our `Trac instance`_ for viewing existing bug reports and
Please use our `bug tracker`_ for viewing existing bug reports and
for submitting new bug reports.

.. _`Trac instance`: http://sourceforge.net/apps/trac/elftoolchain/report
.. _`bug tracker`: https://sourceforge.net/p/elftoolchain/tickets/


Additional Information
Expand All @@ -119,7 +119,7 @@ website`_.

.. _project website: http://elftoolchain.sourceforge.net/

.. $Id: README.rst 3656 2018-12-26 09:46:24Z jkoshy $
.. $Id: README.rst 3677 2019-02-11 09:37:09Z jkoshy $
.. Local Variables:
.. mode: rst
Expand Down
2 changes: 1 addition & 1 deletion contrib/elftoolchain/addr2line/addr2line.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#include "uthash.h"
#include "_elftc.h"

ELFTC_VCSID("$Id: addr2line.c 3544 2017-06-05 14:51:44Z emaste $");
ELFTC_VCSID("$Id: addr2line.c 3499 2016-11-25 16:06:29Z emaste $");

struct Func {
char *name;
Expand Down
44 changes: 40 additions & 4 deletions contrib/elftoolchain/common/elfdefinitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: elfdefinitions.h 3515 2017-01-24 22:04:22Z emaste $
* $Id: elfdefinitions.h 3769 2019-06-29 15:15:02Z emaste $
*/

/*
Expand Down Expand Up @@ -72,7 +72,39 @@ _ELF_DEFINE_DF(DF_TEXTREL, 0x4, \
_ELF_DEFINE_DF(DF_BIND_NOW, 0x8, \
"process relocation entries at load time") \
_ELF_DEFINE_DF(DF_STATIC_TLS, 0x10, \
"uses static thread-local storage")
"uses static thread-local storage") \
_ELF_DEFINE_DF(DF_1_BIND_NOW, 0x1, \
"process relocation entries at load time") \
_ELF_DEFINE_DF(DF_1_GLOBAL, 0x2, \
"unused") \
_ELF_DEFINE_DF(DF_1_GROUP, 0x4, \
"object is a member of a group") \
_ELF_DEFINE_DF(DF_1_NODELETE, 0x8, \
"object cannot be deleted from a process") \
_ELF_DEFINE_DF(DF_1_LOADFLTR, 0x10, \
"immediate load filtees") \
_ELF_DEFINE_DF(DF_1_INITFIRST, 0x20, \
"initialize object first") \
_ELF_DEFINE_DF(DF_1_NOOPEN, 0x40, \
"disallow dlopen()") \
_ELF_DEFINE_DF(DF_1_ORIGIN, 0x80, \
"object being loaded may refer to $ORIGIN") \
_ELF_DEFINE_DF(DF_1_DIRECT, 0x100, \
"direct bindings enabled") \
_ELF_DEFINE_DF(DF_1_INTERPOSE, 0x400, \
"object is interposer") \
_ELF_DEFINE_DF(DF_1_NODEFLIB, 0x800, \
"ignore default library search path") \
_ELF_DEFINE_DF(DF_1_NODUMP, 0x1000, \
"disallow dldump()") \
_ELF_DEFINE_DF(DF_1_CONFALT, 0x2000, \
"object is a configuration alternative") \
_ELF_DEFINE_DF(DF_1_ENDFILTEE, 0x4000, \
"filtee terminates filter search") \
_ELF_DEFINE_DF(DF_1_DISPRELDNE, 0x8000, \
"displacement relocation done") \
_ELF_DEFINE_DF(DF_1_DISPRELPND, 0x10000, \
"displacement relocation pending")
#undef _ELF_DEFINE_DF
#define _ELF_DEFINE_DF(N, V, DESCR) N = V ,
enum {
Expand Down Expand Up @@ -2464,7 +2496,10 @@ _ELF_DEFINE_NT(NT_PSTATUS, 10, "Linux process status") \
_ELF_DEFINE_NT(NT_FPREGS, 12, "Linux floating point regset") \
_ELF_DEFINE_NT(NT_PSINFO, 13, "Linux process information") \
_ELF_DEFINE_NT(NT_LWPSTATUS, 16, "Linux lwpstatus_t type") \
_ELF_DEFINE_NT(NT_LWPSINFO, 17, "Linux lwpinfo_t type")
_ELF_DEFINE_NT(NT_LWPSINFO, 17, "Linux lwpinfo_t type") \
_ELF_DEFINE_NT(NT_FREEBSD_NOINIT_TAG, 2, "FreeBSD no .init tag") \
_ELF_DEFINE_NT(NT_FREEBSD_ARCH_TAG, 3, "FreeBSD arch tag") \
_ELF_DEFINE_NT(NT_FREEBSD_FEATURE_CTL, 4, "FreeBSD feature control")

#undef _ELF_DEFINE_NT
#define _ELF_DEFINE_NT(N, V, DESCR) N = V ,
Expand Down Expand Up @@ -2822,7 +2857,8 @@ typedef struct {

#define ELF64_R_SYM(I) ((I) >> 32)
#define ELF64_R_TYPE(I) ((I) & 0xFFFFFFFFUL)
#define ELF64_R_INFO(S,T) (((S) << 32) + ((T) & 0xFFFFFFFFUL))
#define ELF64_R_INFO(S,T) \
(((Elf64_Xword) (S) << 32) + ((T) & 0xFFFFFFFFUL))

/*
* Symbol versioning structures.
Expand Down
4 changes: 3 additions & 1 deletion contrib/elftoolchain/common/native-elf-format
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
#
# $Id: native-elf-format 3650 2018-11-25 12:06:28Z jkoshy $
# $Id: native-elf-format 3735 2019-04-25 19:44:47Z jkoshy $
#
# Find the native ELF format for a host platform by compiling a
# test object and examining the resulting object.
Expand Down Expand Up @@ -37,6 +37,8 @@ $1 ~ "Machine:" {
elfarch = "EM_MIPS";
} else if (match($0, ".*[xX]86[-_]64")) {
elfarch = "EM_X86_64";
} else if (match($0, "PowerPC64")) {
elfarch = "EM_PPC64";
} else {
elfarch = "unknown";
}
Expand Down
2 changes: 1 addition & 1 deletion contrib/elftoolchain/elfcopy/ascii.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

#include "elfcopy.h"

ELFTC_VCSID("$Id: ascii.c 3487 2016-08-24 18:12:08Z emaste $");
ELFTC_VCSID("$Id: ascii.c 3757 2019-06-28 01:15:28Z emaste $");

static void append_data(struct section *s, const void *buf, size_t sz);
static char hex_digit(uint8_t n);
Expand Down
2 changes: 1 addition & 1 deletion contrib/elftoolchain/elfcopy/binary.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

#include "elfcopy.h"

ELFTC_VCSID("$Id: binary.c 3611 2018-04-16 21:35:18Z jkoshy $");
ELFTC_VCSID("$Id: binary.c 3757 2019-06-28 01:15:28Z emaste $");

/*
* Convert ELF object to `binary'. Sections with SHF_ALLOC flag set
Expand Down
2 changes: 1 addition & 1 deletion contrib/elftoolchain/elfcopy/elfcopy.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: elfcopy.h 3615 2018-05-17 04:12:24Z kaiwang27 $
* $Id: elfcopy.h 3757 2019-06-28 01:15:28Z emaste $
*/

#include <sys/queue.h>
Expand Down
2 changes: 1 addition & 1 deletion contrib/elftoolchain/elfcopy/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

#include "elfcopy.h"

ELFTC_VCSID("$Id: main.c 3577 2017-09-14 02:19:42Z emaste $");
ELFTC_VCSID("$Id: main.c 3757 2019-06-28 01:15:28Z emaste $");

enum options
{
Expand Down
2 changes: 1 addition & 1 deletion contrib/elftoolchain/elfcopy/sections.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

#include "elfcopy.h"

ELFTC_VCSID("$Id: sections.c 3646 2018-10-27 02:25:39Z emaste $");
ELFTC_VCSID("$Id: sections.c 3758 2019-06-28 01:16:50Z emaste $");

static void add_gnu_debuglink(struct elfcopy *ecp);
static uint32_t calc_crc32(const char *p, size_t len, uint32_t crc);
Expand Down
2 changes: 1 addition & 1 deletion contrib/elftoolchain/elfdump/elfdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

#include "_elftc.h"

ELFTC_VCSID("$Id: elfdump.c 3584 2017-11-05 20:51:43Z jkoshy $");
ELFTC_VCSID("$Id: elfdump.c 3762 2019-06-28 21:06:24Z emaste $");

#if defined(ELFTC_NEED_ELF_NOTE_DEFINITION)
#include "native-elf-format.h"
Expand Down
2 changes: 1 addition & 1 deletion contrib/elftoolchain/libdwarf/dwarf.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: dwarf.h 3494 2016-09-20 17:16:13Z emaste $
* $Id: dwarf.h 3749 2019-06-28 01:10:44Z emaste $
*/

#ifndef _DWARF_H_
Expand Down
4 changes: 2 additions & 2 deletions contrib/elftoolchain/libdwarf/dwarf_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

#include "_libdwarf.h"

ELFTC_VCSID("$Id: dwarf_dump.c 3494 2016-09-20 17:16:13Z emaste $");
ELFTC_VCSID("$Id: dwarf_dump.c 3749 2019-06-28 01:10:44Z emaste $");

int
dwarf_get_ACCESS_name(unsigned access, const char **s)
Expand Down Expand Up @@ -605,7 +605,7 @@ dwarf_get_DS_name(unsigned ds, const char **s)
case DW_DS_leading_separate:
*s = "DW_DS_leading_separate"; break;
case DW_DS_trailing_separate:
*s = "DW_DS_trailing_separate";
*s = "DW_DS_trailing_separate"; break;
default:
return (DW_DLV_NO_ENTRY);
}
Expand Down
2 changes: 1 addition & 1 deletion contrib/elftoolchain/libdwarf/libdwarf_attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

#include "_libdwarf.h"

ELFTC_VCSID("$Id: libdwarf_attr.c 3064 2014-06-06 19:35:55Z kaiwang27 $");
ELFTC_VCSID("$Id: libdwarf_attr.c 3748 2019-06-28 01:11:13Z emaste $");

int
_dwarf_attr_alloc(Dwarf_Die die, Dwarf_Attribute *atp, Dwarf_Error *error)
Expand Down
2 changes: 1 addition & 1 deletion contrib/elftoolchain/libdwarf/libdwarf_reloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

#include "_libdwarf.h"

ELFTC_VCSID("$Id: libdwarf_reloc.c 3578 2017-09-14 02:21:28Z emaste $");
ELFTC_VCSID("$Id: libdwarf_reloc.c 3741 2019-06-07 06:32:01Z jkoshy $");

Dwarf_Unsigned
_dwarf_get_reloc_type(Dwarf_P_Debug dbg, int is64)
Expand Down
6 changes: 3 additions & 3 deletions contrib/elftoolchain/libelf/_libelf.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: _libelf.h 3632 2018-10-10 21:12:43Z jkoshy $
* $Id: _libelf.h 3738 2019-05-05 21:49:06Z jkoshy $
*/

#ifndef __LIBELF_H_
Expand Down Expand Up @@ -94,7 +94,7 @@ struct _Elf {
Elf_Kind e_kind; /* ELF_K_* */
Elf *e_parent; /* non-NULL for archive members */
unsigned char *e_rawfile; /* uninterpreted bytes */
size_t e_rawsize; /* size of uninterpreted bytes */
off_t e_rawsize; /* size of uninterpreted bytes */
unsigned int e_version; /* file version */

/*
Expand Down Expand Up @@ -233,7 +233,7 @@ Elf *_libelf_open_object(int _fd, Elf_Cmd _c, int _reporterror);
Elf64_Xword _libelf_mips64el_r_info_tof(Elf64_Xword r_info);
Elf64_Xword _libelf_mips64el_r_info_tom(Elf64_Xword r_info);
struct _Libelf_Data *_libelf_release_data(struct _Libelf_Data *_d);
Elf *_libelf_release_elf(Elf *_e);
void _libelf_release_elf(Elf *_e);
Elf_Scn *_libelf_release_scn(Elf_Scn *_s);
int _libelf_setphnum(Elf *_e, void *_eh, int _elfclass, size_t _phnum);
int _libelf_setshnum(Elf *_e, void *_eh, int _elfclass, size_t _shnum);
Expand Down
8 changes: 7 additions & 1 deletion contrib/elftoolchain/libelf/_libelf_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: _libelf_config.h 3566 2017-08-31 02:28:40Z emaste $
* $Id: _libelf_config.h 3764 2019-06-28 21:44:46Z emaste $
*/

#if defined(__APPLE__) || defined(__DragonFly__)
Expand Down Expand Up @@ -103,6 +103,12 @@
#define LIBELF_BYTEORDER ELFDATA2LSB
#define LIBELF_CLASS ELFCLASS64

#elif defined(__riscv64)

#define LIBELF_ARCH EM_RISCV
#define LIBELF_BYTEORDER ELFDATA2LSB
#define LIBELF_CLASS ELFCLASS64

#elif defined(__sparc__)

#define LIBELF_ARCH EM_SPARCV9
Expand Down
54 changes: 32 additions & 22 deletions contrib/elftoolchain/libelf/elf.3
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.\" Copyright (c) 2006-2008,2011 Joseph Koshy. All rights reserved.
.\" Copyright (c) 2006-2008,2011,2019 Joseph Koshy. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
Expand All @@ -21,9 +21,9 @@
.\" out of the use of this software, even if advised of the possibility of
.\" such damage.
.\"
.\" $Id: elf.3 3643 2018-10-14 21:09:24Z jkoshy $
.\" $Id: elf.3 3743 2019-06-12 19:36:30Z jkoshy $
.\"
.Dd October 10, 2018
.Dd June 12, 2019
.Dt ELF 3
.Os
.Sh NAME
Expand Down Expand Up @@ -266,36 +266,43 @@ The operating version for the data in this buffer.
.El
.Pp
.Vt Elf_Data
descriptors are usually associated with
descriptors are usually used in conjunction with
.Vt Elf_Scn
descriptors.
Existing data descriptors associated with an ELF section may be
structures are retrieved using the
.Fn elf_getdata
and
.Fn elf_rawdata
functions.
The
.Fn elf_newdata
function may be used to attach new data descriptors to an ELF section.
.It Vt Elf_Scn
.Vt Elf_Scn
descriptors represent a section in an ELF object.
descriptors represent sections in an ELF object.
These descriptors are opaque and contain no application modifiable
fields.
.Pp
They are retrieved using the
The
.Vt Elf_Scn
descriptor for a specific section in an ELF object can be
retrieved using the
.Fn elf_getscn
function.
An application may iterate through the existing sections of an ELF
object using the
The sections contained in an ELF object can be traversed using the
.Fn elf_nextscn
function.
New sections may be allocated using the
New sections are allocated using the
.Fn elf_newscn
function.
.Pp
The
.Vt Elf_Scn
descriptor is opaque and contains no application modifiable fields.
.Vt Elf_Data
descriptors associated with a given section can be retrieved
using the
.Fn elf_getdata
function.
New data descriptors can be added to a section
descriptor using the
.Fn elf_newdata
function.
The untranslated
.Dq file
representation of data in a section can be retrieved using the
.Fn elf_rawdata
function.
.El
.Ss Supported Elf Types
The following ELF datatypes are supported by the library.
Expand Down Expand Up @@ -608,8 +615,11 @@ descriptor itself.
.Xr ar 5 ,
.Xr elf 5
.Sh HISTORY
The original ELF(3) API was developed for Unix System V.
The current implementation of the ELF(3) API appeared in
The original
.Nm
API was developed for
.At V .
The current implementation of the API appeared in
.Fx 7.0 .
.Sh AUTHORS
The ELF library was written by
Expand Down
Loading

0 comments on commit ca86244

Please sign in to comment.