emaste b54d7a9715 Update to ELF Tool Chain r3668
Highlights:
- Make sure that only TLS sections are sorted into TLS segment.
- Fixed multiple errors in "Section to Segment mapping".
- Man page updates
- ar improvements
- elfcopy: avoid filter_reloc uninitialized variable for rela
- elfcopy: avoid stripping relocations from static binaries
- readelf: avoid printing directory in front of absolute path
- readelf: add NT_FREEBSD_FEATURE_CTL FreeBSD note type
- test improvements

NOTES:

Some of these changes originated in FreeBSD and simply reduce diffs
between contrib and vendor.

ELF Tool Chain ar is not (currently) used in FreeBSD, and there are
improvements in both FreeBSD and ELF Tool Chain ar that are not in
the other.

Sponsored by:	The FreeBSD Foundation
2019-01-10 14:35:23 +00:00

50 lines
1.2 KiB
Bash
Executable File

#!/bin/sh
#
# $Id: native-elf-format 3650 2018-11-25 12:06:28Z jkoshy $
#
# Find the native ELF format for a host platform by compiling a
# test object and examining the resulting object.
#
# This script is used if there is no easy way to determine this
# information statically at compile time.
program=`basename $0`
tmp_c=`mktemp -u nefXXXXXX`.c
tmp_o=`echo ${tmp_c} | sed -e 's/.c$/.o/'`
trap "rm -f ${tmp_c} ${tmp_o}" 0 1 2 3 15
touch ${tmp_c}
echo "/* Generated by ${program} on `date` */"
cc -c ${tmp_c} -o ${tmp_o}
LC_ALL=C readelf -h ${tmp_o} | awk '
$1 ~ "Class:" {
sub("ELF","",$2); elfclass = $2;
}
$1 ~ "Data:" {
if (match($0, "little")) {
elfdata = "LSB";
} else {
elfdata = "MSB";
}
}
$1 ~ "Machine:" {
if (match($0, "Intel.*386")) {
elfarch = "EM_386";
} else if (match($0, "MIPS")) {
elfarch = "EM_MIPS";
} else if (match($0, ".*[xX]86[-_]64")) {
elfarch = "EM_X86_64";
} else {
elfarch = "unknown";
}
}
END {
printf("#define ELFTC_CLASS ELFCLASS%s\n", elfclass);
printf("#define ELFTC_ARCH %s\n", elfarch);
printf("#define ELFTC_BYTEORDER ELFDATA2%s\n", elfdata);
}'