Re: svn commit: r292120 - in head/contrib/elftoolchain: addr2line common elfcopy libelf readelf
2015-12-13 7:04 GMT+01:00 Adrian Chadd: > Hm! > > cc1: warnings being treated as errors > > /usr/home/adrian/work/freebsd/head-embedded/src/usr.bin/readelf/../../contrib/elftoolchain/readelf/readelf.c: > In function 'dump_dwarf': > > /usr/home/adrian/work/freebsd/head-embedded/src/usr.bin/readelf/../../contrib/elftoolchain/readelf/readelf.c:7479: > warning: 'b' may be used uninitialized in this function > > /usr/home/adrian/work/freebsd/head-embedded/src/usr.bin/readelf/../../contrib/elftoolchain/readelf/readelf.c:7479: > note: 'b' was declared here > > /usr/home/adrian/work/freebsd/head-embedded/src/usr.bin/readelf/../../contrib/elftoolchain/readelf/readelf.c:4758: > warning: 'pe' may be used uninitialized in this function > > /usr/home/adrian/work/freebsd/head-embedded/src/usr.bin/readelf/../../contrib/elftoolchain/readelf/readelf.c:4758: > note: 'pe' was declared here > > .. these both seem like legit. > > Hi, Sorry about the breakage. Should be fixed by r292158. Somehow clang didn't catch this. Had to use gcc to see this warning. Thanks, Kai ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r292158 - head/contrib/elftoolchain/readelf
Author: kaiw Date: Sun Dec 13 08:27:14 2015 New Revision: 292158 URL: https://svnweb.freebsd.org/changeset/base/292158 Log: Fixed uninitialized variable warnings. Modified: head/contrib/elftoolchain/readelf/readelf.c Modified: head/contrib/elftoolchain/readelf/readelf.c == --- head/contrib/elftoolchain/readelf/readelf.c Sun Dec 13 08:23:45 2015 (r292157) +++ head/contrib/elftoolchain/readelf/readelf.c Sun Dec 13 08:27:14 2015 (r292158) @@ -4814,6 +4814,7 @@ dump_dwarf_line(struct readelf *re) } endoff = offset + length; + pe = (uint8_t *) d->d_buf + endoff; version = re->dw_read(d, , 2); hdrlen = re->dw_read(d, , dwarf_size); minlen = re->dw_read(d, , 1); @@ -4879,7 +4880,6 @@ dump_dwarf_line(struct readelf *re) #defineADDRESS(x) x) - opbase) / lrange) * minlen) p++; - pe = (uint8_t *) d->d_buf + endoff; printf("\n"); printf(" Line Number Statements:\n"); @@ -7476,7 +7476,7 @@ static int64_t _decode_sleb128(uint8_t **dp, uint8_t *dpe) { int64_t ret = 0; - uint8_t b; + uint8_t b = 0; int shift = 0; uint8_t *src = *dp; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r261259 - head/cddl/contrib/opensolaris/tools/ctf/cvt
Author: kaiw Date: Wed Jan 29 09:58:05 2014 New Revision: 261259 URL: http://svnweb.freebsd.org/changeset/base/261259 Log: Only declare `bysz' variable under little endian archs. Modified: head/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c Modified: head/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c == --- head/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c Wed Jan 29 05:58:08 2014(r261258) +++ head/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c Wed Jan 29 09:58:05 2014(r261259) @@ -935,7 +935,10 @@ static void die_sou_create(dwarf_t *dw, Dwarf_Die str, Dwarf_Off off, tdesc_t *tdp, int type, const char *typename) { - Dwarf_Unsigned sz, bysz, bitsz, bitoff, maxsz=0; + Dwarf_Unsigned sz, bitsz, bitoff, maxsz=0; +#if BYTE_ORDER == _LITTLE_ENDIAN + Dwarf_Unsigned bysz; +#endif Dwarf_Die mem; mlist_t *ml, **mlastp; iidesc_t *ii; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r261246 - in head: . cddl/contrib/opensolaris/tools/ctf/cvt contrib/elftoolchain lib/libdwarf lib/libelf sys/sys
Author: kaiw Date: Tue Jan 28 21:38:54 2014 New Revision: 261246 URL: http://svnweb.freebsd.org/changeset/base/261246 Log: Merge from projects/elftoolchain: Upgrade libelf and libdwarf to newer versions from elftoolchain upstream (r2974). Convert ctfconvert to use the APIs from the new libdwarf and make ctfconvert work with Clang 3.4. __FreeBSD_version is bumped to 116. A list of notable changes: [libelf] * The old libelf source code in lib/libelf has been removed. Instead, the new libelf is built from contrib/elftoolchain/libelf. * Manual pages are largely improved. * Internal implementation was refactored and improved for better correctness and portability. * Fixed a few memory leaks. * Extended with extension APIs `elf_open()` and `elf_openmemory()`. These APIs are similar to `elf_begin()` and `elf_memory()` respectively, except that they return an ELF descriptor of kind `ELF_K_NONE` instead of an error if the object being opened could not be parsed. * Implement support for translating sections of type ELF_T_VDEF and ELF_T_VNEED. * Improve `elf_update()` to check that the executable header, the program header table, section contents and the section header table do not overlap, and to ensure that gaps between extents are filled with the fill character specified by `elf_fill()`. * Allow `Elf_Data` descriptors to have types and alignments differing from their containing section. * Remove functionality controlled by `LIBELF_TEST_HOOKS`. * Support processing of BSD-flavor archives. * Add knowledge of section types `SHT_GNU_ATTRIBUTES` and `SHT_GNU_LIBLIST`. * Use elftoolchain style symbol versioning. * Shared library version is bumped. [libdwarf] * The old libdwarf source code in lib/libdwarf has been removed. Instead, the new libdwarf is built from contrib/elftoolchain/libdwarf. * Support full DWARF3 and partial DWARF4 parsing. * Support DWARF2 generation. * Support for DWARF line number, call frame, location expression, macro info and address ranges, among other things. * The APIs for the new libdwarf are mostly compatible with the widely used LGPL libdwarf. Some of the incompatible APIs from the old libdwarf are kept as its own extensions. All the APIs are documented. * Use elftoolchain style symbol versioning. * Shared library version is bumped. [ctfconvert] * Switch to the APIs from the new libdwarf. * Improve die_mem_offset() so that DW_AT_data_member_location attributes generated by Clang 3.4 can be handled properly. * Make use of DW_AT_byte_size attribute of the member DIE to calculate the bits occupied by the member's type, without actually resolving the type. This way ctfconvert can deal with the case that Clang 3.4 sometimes emits DIE for struct/union member before emitting the DIE for the type of that member. Obtained from:elftoolchain No objection: -toolchain mailing list Added: head/contrib/elftoolchain/ - copied from r261245, projects/elftoolchain/contrib/elftoolchain/ Deleted: head/lib/libdwarf/_libdwarf.h head/lib/libdwarf/dwarf.h head/lib/libdwarf/dwarf_abbrev.c head/lib/libdwarf/dwarf_attr.c head/lib/libdwarf/dwarf_attrval.c head/lib/libdwarf/dwarf_cu.c head/lib/libdwarf/dwarf_dealloc.c head/lib/libdwarf/dwarf_die.c head/lib/libdwarf/dwarf_dump.c head/lib/libdwarf/dwarf_errmsg.c head/lib/libdwarf/dwarf_errno.c head/lib/libdwarf/dwarf_finish.c head/lib/libdwarf/dwarf_form.c head/lib/libdwarf/dwarf_func.c head/lib/libdwarf/dwarf_init.c head/lib/libdwarf/dwarf_loc.c head/lib/libdwarf/libdwarf.h head/lib/libelf/README head/lib/libelf/Version.map head/lib/libelf/_libelf.h head/lib/libelf/elf.3 head/lib/libelf/elf_begin.3 head/lib/libelf/elf_begin.c head/lib/libelf/elf_cntl.3 head/lib/libelf/elf_cntl.c head/lib/libelf/elf_data.c head/lib/libelf/elf_end.3 head/lib/libelf/elf_end.c head/lib/libelf/elf_errmsg.3 head/lib/libelf/elf_errmsg.c head/lib/libelf/elf_errno.c head/lib/libelf/elf_fill.3 head/lib/libelf/elf_fill.c head/lib/libelf/elf_flag.c head/lib/libelf/elf_flagdata.3 head/lib/libelf/elf_getarhdr.3 head/lib/libelf/elf_getarhdr.c head/lib/libelf/elf_getarsym.3 head/lib/libelf/elf_getarsym.c head/lib/libelf/elf_getbase.3 head/lib/libelf/elf_getbase.c head/lib/libelf/elf_getdata.3 head/lib/libelf/elf_getident.3 head/lib/libelf/elf_getident.c head/lib/libelf/elf_getphdrnum.3 head/lib/libelf/elf_getphnum.3 head/lib/libelf/elf_getscn.3 head/lib/libelf/elf_getshdrnum.3 head/lib/libelf/elf_getshdrstrndx.3 head/lib/libelf/elf_getshnum.3 head/lib/libelf/elf_getshstrndx.3 head/lib/libelf/elf_hash.3 head/lib/libelf/elf_hash.c head/lib/libelf/elf_kind.3 head/lib/libelf/elf_kind.c head/lib/libelf/elf_memory.3 head/lib/libelf/elf_memory.c head/lib/libelf/elf_next.3
Re: svn commit: r261246 - in head: . cddl/contrib/opensolaris/tools/ctf/cvt contrib/elftoolchain lib/libdwarf lib/libelf sys/sys
On Tue, Jan 28, 2014 at 03:01:39PM -0800, Adrian Chadd wrote: .. and was this tested on anything other than i386/amd64? Don't be too hasty to MFC; us guys in ARM, PPC, MIPS, SPARC and IA64 world have to now retest everything. It'll take time for this to shake out. Of course! I can help with troubleshooting CTF, libdwarf, libelf related issues on these platforms, if needed. Also I need to complete the DWARF4 support in libdwarf/ctfconvert, which definitely will consume some time. After that, we can consider MFC if everything runs ok on all these platforms. Thanks, Kai ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
Re: svn commit: r261246 - in head: . cddl/contrib/opensolaris/tools/ctf/cvt contrib/elftoolchain lib/libdwarf lib/libelf sys/sys
On Tue, Jan 28, 2014 at 05:37:11PM -0500, Pedro Giffuni wrote: 2) We start seeing more of those binutils replacements[1] in elftoolchain find their way into the tree now that they are already in the vendor area. Yes I will try to do that later. Some of the binutils replacements in elftoolchain were almost ready. We just need to do more testing and to probably implement new features found in more recent binutils. Thanks, Kai ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r260683 - svnadmin/conf
Author: kaiw Date: Wed Jan 15 08:40:10 2014 New Revision: 260683 URL: http://svnweb.freebsd.org/changeset/base/260683 Log: Add my name for elftoolchain import. Modified: svnadmin/conf/sizelimit.conf Modified: svnadmin/conf/sizelimit.conf == --- svnadmin/conf/sizelimit.confWed Jan 15 08:17:31 2014 (r260682) +++ svnadmin/conf/sizelimit.confWed Jan 15 08:40:10 2014 (r260683) @@ -36,3 +36,4 @@ rwatson sam stas thompsa +kaiw ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r260685 - vendor/elftoolchain/elftoolchain-r2974
Author: kaiw Date: Wed Jan 15 08:47:57 2014 New Revision: 260685 URL: http://svnweb.freebsd.org/changeset/base/260685 Log: Tag elftoolchain-r2974. Added: vendor/elftoolchain/elftoolchain-r2974/ - copied from r260684, vendor/elftoolchain/dist/ ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r260686 - svnadmin/conf
Author: kaiw Date: Wed Jan 15 08:49:47 2014 New Revision: 260686 URL: http://svnweb.freebsd.org/changeset/base/260686 Log: Remove myself after the import was done. Modified: svnadmin/conf/sizelimit.conf Modified: svnadmin/conf/sizelimit.conf == --- svnadmin/conf/sizelimit.confWed Jan 15 08:47:57 2014 (r260685) +++ svnadmin/conf/sizelimit.confWed Jan 15 08:49:47 2014 (r260686) @@ -36,4 +36,3 @@ rwatson sam stas thompsa -kaiw ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r252430 - head/lib/libdwarf
Author: kaiw Date: Sun Jun 30 21:06:47 2013 New Revision: 252430 URL: http://svnweb.freebsd.org/changeset/base/252430 Log: When decoding SLEB128, make sure sign extension is performed for 64-bit integers. MFC after:3 days Modified: head/lib/libdwarf/dwarf_init.c head/lib/libdwarf/dwarf_loc.c Modified: head/lib/libdwarf/dwarf_init.c == --- head/lib/libdwarf/dwarf_init.c Sun Jun 30 20:51:15 2013 (r252429) +++ head/lib/libdwarf/dwarf_init.c Sun Jun 30 21:06:47 2013 (r252430) @@ -192,7 +192,7 @@ dwarf_read_sleb128(Elf_Data **dp, uint64 shift += 7; } while ((b 0x80) != 0); - if (shift 32 (b 0x40) != 0) + if (shift 64 (b 0x40) != 0) ret |= (-1 shift); return ret; Modified: head/lib/libdwarf/dwarf_loc.c == --- head/lib/libdwarf/dwarf_loc.c Sun Jun 30 20:51:15 2013 (r252429) +++ head/lib/libdwarf/dwarf_loc.c Sun Jun 30 21:06:47 2013 (r252430) @@ -46,7 +46,7 @@ dwarf_decode_sleb128(uint8_t **dp) shift += 7; } while ((b 0x80) != 0); - if (shift 32 (b 0x40) != 0) + if (shift 64 (b 0x40) != 0) ret |= (-1 shift); *dp = src; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r231703 - stable/8/lib/libelf
Author: kaiw Date: Tue Feb 14 19:48:57 2012 New Revision: 231703 URL: http://svn.freebsd.org/changeset/base/231703 Log: MFC r221595: For zero-sized sections, set the `d_buf` field of the `Elf_Data` descriptor returned by `elf_rawdata()` to NULL. Modified: stable/8/lib/libelf/elf_data.c Directory Properties: stable/8/lib/libelf/ (props changed) Modified: stable/8/lib/libelf/elf_data.c == --- stable/8/lib/libelf/elf_data.c Tue Feb 14 19:36:35 2012 (r231702) +++ stable/8/lib/libelf/elf_data.c Tue Feb 14 19:48:57 2012 (r231703) @@ -223,7 +223,8 @@ elf_rawdata(Elf_Scn *s, Elf_Data *d) if ((d = _libelf_allocate_data(s)) == NULL) return (NULL); - d-d_buf = sh_type == SHT_NOBITS ? NULL : e-e_rawfile + sh_offset; + d-d_buf = (sh_type == SHT_NOBITS || sh_size == 0) ? NULL : + e-e_rawfile + sh_offset; d-d_off = 0; d-d_align = sh_align; d-d_size= sh_size; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r231706 - stable/8/lib/libelf
Author: kaiw Date: Tue Feb 14 19:50:41 2012 New Revision: 231706 URL: http://svn.freebsd.org/changeset/base/231706 Log: MFC r221598: Document the behavior of `elf_getdata()` and `elf_rawdata()` with zero-sized ELF sections. Modified: stable/8/lib/libelf/elf_getdata.3 Directory Properties: stable/8/lib/libelf/ (props changed) Modified: stable/8/lib/libelf/elf_getdata.3 == --- stable/8/lib/libelf/elf_getdata.3 Tue Feb 14 19:49:36 2012 (r231705) +++ stable/8/lib/libelf/elf_getdata.3 Tue Feb 14 19:50:41 2012 (r231706) @@ -1,4 +1,4 @@ -.\ Copyright (c) 2006,2008,2010 Joseph Koshy. All rights reserved. +.\ Copyright (c) 2006,2008,2010-2011 Joseph Koshy. All rights reserved. .\ .\ Redistribution and use in source and binary forms, with or without .\ modification, are permitted provided that the following conditions @@ -23,7 +23,7 @@ .\ .\ $FreeBSD$ .\ -.Dd April 30, 2010 +.Dd January 26, 2011 .Dt ELF_GETDATA 3 .Os .Sh NAME @@ -142,9 +142,10 @@ always returns .Vt Elf_Data structures of type .Dv ELF_T_BYTE . -.Ss Special handling of SHT_NOBITS sections +.Ss Special handling of zero-sized and SHT_NOBITS sections For sections of type -.Dv SHT_NOBITS , +.Dv SHT_NOBITS, +and for zero-sized sections, the functions .Fn elf_getdata and ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r221586 - stable/8/usr.bin/ar
Author: kaiw Date: Sat May 7 10:08:01 2011 New Revision: 221586 URL: http://svn.freebsd.org/changeset/base/221586 Log: MFC r201166 (kientzle): ar only needs to support ar format. Modified: stable/8/usr.bin/ar/acpyacc.y stable/8/usr.bin/ar/read.c Directory Properties: stable/8/usr.bin/ar/ (props changed) Modified: stable/8/usr.bin/ar/acpyacc.y == --- stable/8/usr.bin/ar/acpyacc.y Sat May 7 10:06:43 2011 (r221585) +++ stable/8/usr.bin/ar/acpyacc.y Sat May 7 10:08:01 2011 (r221586) @@ -251,7 +251,7 @@ arscp_open(char *fname) if ((a = archive_read_new()) == NULL) bsdar_errc(bsdar, EX_SOFTWARE, 0, archive_read_new failed); archive_read_support_compression_all(a); - archive_read_support_format_all(a); + archive_read_support_format_ar(a); AC(archive_read_open_file(a, fname, DEF_BLKSZ)); if ((r = archive_read_next_header(a, entry))) bsdar_warnc(bsdar, 0, %s, archive_error_string(a)); Modified: stable/8/usr.bin/ar/read.c == --- stable/8/usr.bin/ar/read.c Sat May 7 10:06:43 2011(r221585) +++ stable/8/usr.bin/ar/read.c Sat May 7 10:08:01 2011(r221586) @@ -88,7 +88,7 @@ read_archive(struct bsdar *bsdar, char m if ((a = archive_read_new()) == NULL) bsdar_errc(bsdar, EX_SOFTWARE, 0, archive_read_new failed); archive_read_support_compression_all(a); - archive_read_support_format_all(a); + archive_read_support_format_ar(a); AC(archive_read_open_file(a, bsdar-filename, DEF_BLKSZ)); for (;;) { ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r221587 - stable/8/usr.bin/ar
Author: kaiw Date: Sat May 7 10:23:07 2011 New Revision: 221587 URL: http://svn.freebsd.org/changeset/base/221587 Log: MFC r208189: Removed ar(1)'s support for compressed archives. This change removes ar(1)'s dependencies on compressor libraries -lz, -lbz2 and -llzma and fixes building HEAD on some versions of FreeBSD[78]. Option -j and -z is now accepted but ignored. Compressed ar(1) archives are not useful without a ld(1) that can read them. Also, the current ar(1) compression scheme prevents random access of archive members and needs to be redesigned anyway. Modified: stable/8/usr.bin/ar/Makefile stable/8/usr.bin/ar/acpyacc.y stable/8/usr.bin/ar/ar.1 stable/8/usr.bin/ar/ar.c stable/8/usr.bin/ar/ar.h stable/8/usr.bin/ar/read.c stable/8/usr.bin/ar/write.c Directory Properties: stable/8/usr.bin/ar/ (props changed) Modified: stable/8/usr.bin/ar/Makefile == --- stable/8/usr.bin/ar/MakefileSat May 7 10:08:01 2011 (r221586) +++ stable/8/usr.bin/ar/MakefileSat May 7 10:23:07 2011 (r221587) @@ -5,15 +5,8 @@ SRCS= ar.c acplex.l acpyacc.y read.c uti WARNS?=5 -DPADD= ${LIBARCHIVE} ${LIBBZ2} ${LIBZ} ${LIBELF} -LDADD= -larchive -lbz2 -lz -lelf - -# Do not depend on liblzma if we are building the bootstrap-tools and -# the local system doesn't include liblzma -.if !defined(BOOTSTRAPPING) || ${BOOTSTRAPPING} = 800505 -DPADD+=${LIBLZMA} -LDADD+=-llzma -.endif +DPADD= ${LIBARCHIVE} ${LIBELF} +LDADD= -larchive -lelf CFLAGS+=-I. -I${.CURDIR} Modified: stable/8/usr.bin/ar/acpyacc.y == --- stable/8/usr.bin/ar/acpyacc.y Sat May 7 10:08:01 2011 (r221586) +++ stable/8/usr.bin/ar/acpyacc.y Sat May 7 10:23:07 2011 (r221587) @@ -250,7 +250,7 @@ arscp_open(char *fname) if ((a = archive_read_new()) == NULL) bsdar_errc(bsdar, EX_SOFTWARE, 0, archive_read_new failed); - archive_read_support_compression_all(a); + archive_read_support_compression_none(a); archive_read_support_format_ar(a); AC(archive_read_open_file(a, fname, DEF_BLKSZ)); if ((r = archive_read_next_header(a, entry))) Modified: stable/8/usr.bin/ar/ar.1 == --- stable/8/usr.bin/ar/ar.1Sat May 7 10:08:01 2011(r221586) +++ stable/8/usr.bin/ar/ar.1Sat May 7 10:23:07 2011(r221587) @@ -23,7 +23,7 @@ .\ .\ $FreeBSD$ .\ -.Dd August 31, 2007 +.Dd May 17, 2010 .Dt AR 1 .Os .Sh NAME @@ -186,8 +186,7 @@ Synonymous with option Synonymous with option .Fl b . .It Fl j -Compress the resulting archive with -.Xr bzip2 1 . +This option is accepted but ignored. .It Fl m Move archive members specified by arguments .Ar files ... @@ -344,8 +343,7 @@ of extraction unless the .Fl o option was specified. .It Fl z -Compress the resulting archive with -.Xr gzip 1 . +This option is accepted but ignored. .El .Sh EXAMPLES To create a new archive Modified: stable/8/usr.bin/ar/ar.c == --- stable/8/usr.bin/ar/ar.cSat May 7 10:08:01 2011(r221586) +++ stable/8/usr.bin/ar/ar.cSat May 7 10:23:07 2011(r221587) @@ -178,7 +178,7 @@ main(int argc, char **argv) bsdar-options |= AR_TR; break; case 'j': - bsdar-options |= AR_J; + /* ignored */ break; case 'l': /* ignored, for GNU ar comptibility */ @@ -223,7 +223,7 @@ main(int argc, char **argv) set_mode(bsdar, opt); break; case 'z': - bsdar-options |= AR_Z; + /* ignored */ break; case OPTION_HELP: bsdar_usage(); Modified: stable/8/usr.bin/ar/ar.h == --- stable/8/usr.bin/ar/ar.hSat May 7 10:08:01 2011(r221586) +++ stable/8/usr.bin/ar/ar.hSat May 7 10:23:07 2011(r221587) @@ -81,7 +81,6 @@ struct bsdar { const char *addlib; /* target of ADDLIB. */ const char *posarg; /* position arg for modifiers -a, -b. */ char mode; /* program mode */ - char compression; /* compression mode */ int options; /* command line options */ const char *progname; /* program name */ Modified: stable/8/usr.bin/ar/read.c == --- stable/8/usr.bin/ar/read.c Sat May 7 10:08:01
svn commit: r221588 - stable/8/usr.bin/ar
Author: kaiw Date: Sat May 7 10:27:23 2011 New Revision: 221588 URL: http://svn.freebsd.org/changeset/base/221588 Log: MFC r213643 (kientzle): Add -D (deterministic) option to ar. When set, it forces all timestamps and owners to zero and modes to 0644. Useful for producing libraries that are bitwise identical across multiple build runs. Modified: stable/8/usr.bin/ar/ar.1 stable/8/usr.bin/ar/ar.c stable/8/usr.bin/ar/ar.h stable/8/usr.bin/ar/write.c Directory Properties: stable/8/usr.bin/ar/ (props changed) Modified: stable/8/usr.bin/ar/ar.1 == --- stable/8/usr.bin/ar/ar.1Sat May 7 10:23:07 2011(r221587) +++ stable/8/usr.bin/ar/ar.1Sat May 7 10:27:23 2011(r221588) @@ -62,6 +62,7 @@ .Op Fl a Ar position-after .Op Fl b Ar position-before .Op Fl c +.Op Fl D .Op Fl i Ar position-before .Op Fl j .Op Fl s @@ -179,6 +180,16 @@ from the archive specified by argument .Ar archive . The archive's symbol table, if present, is updated to reflect the new contents of the archive. +.It Fl D +When used in combination with the +.Fl r +or +.Fl q +option, insert 0's instead of the real mtime, uid and gid values +and 0644 instead of file mode from the members named by arguments +.Ar files ... . +This ensures that checksums on the resulting archives are reproducible +when member contents are identical. .It Fl f Synonymous with option .Fl T . Modified: stable/8/usr.bin/ar/ar.c == --- stable/8/usr.bin/ar/ar.cSat May 7 10:23:07 2011(r221587) +++ stable/8/usr.bin/ar/ar.cSat May 7 10:27:23 2011(r221588) @@ -154,7 +154,7 @@ main(int argc, char **argv) } } - while ((opt = getopt_long(argc, argv, abCcdfijlMmopqrSsTtuVvxz, + while ((opt = getopt_long(argc, argv, abCcdDfijlMmopqrSsTtuVvxz, longopts, NULL)) != -1) { switch(opt) { case 'a': @@ -173,6 +173,9 @@ main(int argc, char **argv) case 'd': set_mode(bsdar, opt); break; + case 'D': + bsdar-options |= AR_D; + break; case 'f': case 'T': bsdar-options |= AR_TR; @@ -269,6 +272,8 @@ main(int argc, char **argv) only_mode(bsdar, -c, qr); if (bsdar-options AR_CC) only_mode(bsdar, -C, x); + if (bsdar-options AR_D) + only_mode(bsdar, -D, qr); if (bsdar-options AR_O) only_mode(bsdar, -o, x); if (bsdar-options AR_SS) @@ -356,9 +361,9 @@ bsdar_usage() (void)fprintf(stderr, \tar -m [-Tjsvz] archive file ...\n); (void)fprintf(stderr, \tar -m [-Tabijsvz] position archive file ...\n); (void)fprintf(stderr, \tar -p [-Tv] archive [file ...]\n); - (void)fprintf(stderr, \tar -q [-Tcjsvz] archive file ...\n); - (void)fprintf(stderr, \tar -r [-Tcjsuvz] archive file ...\n); - (void)fprintf(stderr, \tar -r [-Tabcijsuvz] position archive file ...\n); + (void)fprintf(stderr, \tar -q [-TcDjsvz] archive file ...\n); + (void)fprintf(stderr, \tar -r [-TcDjsuvz] archive file ...\n); + (void)fprintf(stderr, \tar -r [-TabcDijsuvz] position archive file ...\n); (void)fprintf(stderr, \tar -s [-jz] archive\n); (void)fprintf(stderr, \tar -t [-Tv] archive [file ...]\n); (void)fprintf(stderr, \tar -x [-CTouv] archive [file ...]\n); Modified: stable/8/usr.bin/ar/ar.h == --- stable/8/usr.bin/ar/ar.hSat May 7 10:23:07 2011(r221587) +++ stable/8/usr.bin/ar/ar.hSat May 7 10:27:23 2011(r221588) @@ -43,6 +43,7 @@ #define AR_U 0x0200 /* only extract or update newer members.*/ #define AR_V 0x0400 /* verbose mode */ #define AR_Z 0x0800 /* gzip compression */ +#define AR_D 0x1000 /* insert dummy mode, mtime, uid and gid */ #define DEF_BLKSZ 10240/* default block size */ Modified: stable/8/usr.bin/ar/write.c == --- stable/8/usr.bin/ar/write.c Sat May 7 10:23:07 2011(r221587) +++ stable/8/usr.bin/ar/write.c Sat May 7 10:27:23 2011(r221588) @@ -163,11 +163,24 @@ create_obj_from_file(struct bsdar *bsdar if (mtime != 0 bsdar-options AR_U sb.st_mtime = mtime) goto giveup; - obj-uid = sb.st_uid; - obj-gid = sb.st_gid; - obj-md = sb.st_mode; + /* +* When option '-D' is specified, mtime and UID / GID from the file +* will be replaced with 0, and file mode with 644. This ensures that +* checksums will match for two archives
svn commit: r221589 - stable/8/usr.bin/ar
Author: kaiw Date: Sat May 7 10:31:34 2011 New Revision: 221589 URL: http://svn.freebsd.org/changeset/base/221589 Log: MFC r216014: Add option -D for ranlib(1). When -D is speicified, ranlib(1) will generate a deterministic archive symbol table (i.e. timestamp for the symbol table member header is set to 0). Submitted by:Erik Cederstrand Modified: stable/8/usr.bin/ar/ar.1 stable/8/usr.bin/ar/ar.c Directory Properties: stable/8/usr.bin/ar/ (props changed) Modified: stable/8/usr.bin/ar/ar.1 == --- stable/8/usr.bin/ar/ar.1Sat May 7 10:27:23 2011(r221588) +++ stable/8/usr.bin/ar/ar.1Sat May 7 10:31:34 2011(r221589) @@ -92,6 +92,7 @@ .Ar archive .Op Ar files ... .Nm ranlib +.Op Fl D .Ar archive ... .Sh DESCRIPTION The Modified: stable/8/usr.bin/ar/ar.c == --- stable/8/usr.bin/ar/ar.cSat May 7 10:27:23 2011(r221588) +++ stable/8/usr.bin/ar/ar.cSat May 7 10:31:34 2011(r221589) @@ -113,12 +113,15 @@ main(int argc, char **argv) len = strlen(bsdar-progname); if (len = strlen(ranlib) strcmp(bsdar-progname + len - strlen(ranlib), ranlib) == 0) { - while ((opt = getopt_long(argc, argv, tV, longopts, + while ((opt = getopt_long(argc, argv, tDV, longopts, NULL)) != -1) { switch(opt) { case 't': /* Ignored. */ break; + case 'D': + bsdar-options |= AR_D; + break; case 'V': ranlib_version(); break; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r221590 - stable/8/usr.bin/ar
Author: kaiw Date: Sat May 7 10:32:52 2011 New Revision: 221590 URL: http://svn.freebsd.org/changeset/base/221590 Log: MFC r216716: * Add mention of the `-f`, `-q`, `-S`, and `-V` options in the synopsis section. * Document the `-l`, `-M` and `-S` options. * Improve the text describing the behavior of the `-r` option. * Start a section on standard compliance. * Indicate in the synopsis that the `-S` and `-s` options are mutually exclusive. Modified: stable/8/usr.bin/ar/ar.1 Directory Properties: stable/8/usr.bin/ar/ (props changed) Modified: stable/8/usr.bin/ar/ar.1 == --- stable/8/usr.bin/ar/ar.1Sat May 7 10:31:34 2011(r221589) +++ stable/8/usr.bin/ar/ar.1Sat May 7 10:32:52 2011(r221590) @@ -34,28 +34,42 @@ .Nm .Fl d .Op Fl T +.Op Fl f .Op Fl j .Op Fl v .Op Fl z .Ar archive -.Ar files ... +.Ar .Nm .Fl m .Op Fl T .Op Fl a Ar position-after .Op Fl b Ar position-before +.Op Fl f .Op Fl i Ar position-before .Op Fl j -.Op Fl s +.Op Fl s | Fl S .Op Fl z .Ar archive -.Ar files ... +.Ar .Nm .Fl p .Op Fl T +.Op Fl f .Op Fl v .Ar archive -.Op Ar files ... +.Op Ar +.Nm +.Fl q +.Op Fl T +.Op Fl c +.Op Fl D +.Op Fl f +.Op Fl s | Fl S +.Op Fl v +.Op Fl z +.Ar archive +.Ar .Nm .Fl r .Op Fl T @@ -63,14 +77,15 @@ .Op Fl b Ar position-before .Op Fl c .Op Fl D +.Op Fl f .Op Fl i Ar position-before .Op Fl j -.Op Fl s +.Op Fl s | Fl S .Op Fl u .Op Fl v .Op Fl z .Ar archive -.Ar files ... +.Ar .Nm .Fl s .Op Fl j @@ -78,19 +93,23 @@ .Ar archive .Nm .Fl t +.Op Fl f .Op Fl T .Op Fl v .Ar archive -.Op Ar files ... +.Op Ar .Nm .Fl x .Op Fl C .Op Fl T +.Op Fl f .Op Fl o .Op Fl u .Op Fl v .Ar archive -.Op Ar files ... +.Op Ar +.Nm +.Fl M .Nm ranlib .Op Fl D .Ar archive ... @@ -141,13 +160,13 @@ When used with option .Fl m this option specifies that the archive members specified by arguments -.Ar files ... +.Ar are moved to after the archive member named by argument .Ar member-after . When used with option .Fl r this option specifies that the files specified by arguments -.Ar files ... +.Ar are added after the archive member named by argument .Ar member-after . .It Fl b Ar member-before @@ -155,13 +174,13 @@ When used with option .Fl m this option specifies that the archive members specified by arguments -.Ar files ... +.Ar are moved to before the archive member named by argument .Ar member-before . When used with option .Fl r this option specifies that the files specified by arguments -.Ar files ... +.Ar are added before the archive member named by argument .Ar member-before . .It Fl c @@ -176,7 +195,7 @@ Prevent extracted files from replacing l in the file system. .It Fl d Delete the members named by arguments -.Ar files ... +.Ar from the archive specified by argument .Ar archive . The archive's symbol table, if present, is updated to reflect @@ -188,7 +207,7 @@ or .Fl q option, insert 0's instead of the real mtime, uid and gid values and 0644 instead of file mode from the members named by arguments -.Ar files ... . +.Ar . This ensures that checksums on the resulting archives are reproducible when member contents are identical. .It Fl f @@ -199,9 +218,13 @@ Synonymous with option .Fl b . .It Fl j This option is accepted but ignored. +.It Fl l +This option is accepted for compatibility with GNU +.Xr ar 1 , +but is ignored. .It Fl m Move archive members specified by arguments -.Ar files ... +.Ar within the archive. If a position has been specified by one of the .Fl a , @@ -214,19 +237,21 @@ If no position has been specified, the s to the end of the archive. If the archive has a symbol table, it is updated to reflect the new contents of the archive. +.It Fl M +Read and execute MRI librarian commands from standard input. .It Fl o Preserve the original modification times of members when extracting them. .It Fl p Write the contents of the specified archive members named by arguments -.Ar files ... +.Ar to standard output. If no members were specified, the contents of all the files in the archive are written in the order they appear in the archive. .It Fl q Append the files specified by arguments -.Ar files ... +.Ar to the archive specified by argument .Ar archive without checking if the files already exist in the archive and @@ -241,14 +266,14 @@ option will update the archive's symbol table. .It Fl r Replace (add) the files specified by arguments -.Ar files ... +.Ar in the archive specified by argument .Ar archive , creating the archive if necessary. -Files that replace existing files do not change the order of files -within the archive. +Replacing existing members will not change the order of members within +the archive. If a file named in arguments -.Ar files ... +.Ar does not exist, existing members in the archive that match that name are not changed. New files are added to the
svn commit: r221591 - stable/8/usr.bin/ar
Author: kaiw Date: Sat May 7 10:33:59 2011 New Revision: 221591 URL: http://svn.freebsd.org/changeset/base/221591 Log: MFC r216717: Improve the description of the `-q` option. Modified: stable/8/usr.bin/ar/ar.1 Directory Properties: stable/8/usr.bin/ar/ (props changed) Modified: stable/8/usr.bin/ar/ar.1 == --- stable/8/usr.bin/ar/ar.1Sat May 7 10:32:52 2011(r221590) +++ stable/8/usr.bin/ar/ar.1Sat May 7 10:33:59 2011(r221591) @@ -141,10 +141,7 @@ utility can create and manage an archive .Xr ar 5 ) used to speed up link editing operations. If a symbol table is present in an archive, it will be -kept up-to-date by subsequent operations on the archive (excepting -the quick update specified by the -.Fl q -option). +kept up-to-date by subsequent operations on the archive. .Pp The .Nm ranlib @@ -254,16 +251,11 @@ Append the files specified by arguments .Ar to the archive specified by argument .Ar archive -without checking if the files already exist in the archive and -without updating the archive's symbol table. -If the archive file +without checking if the files already exist in the archive. +The archive symbol table will be updated as needed. +If the file specified by the argument .Ar archive -does not already exist, a new archive is created. -However, to be compatible with GNU -.Nm , -option -.Fl q -will update the archive's symbol table. +does not already exist, a new archive will be created. .It Fl r Replace (add) the files specified by arguments .Ar ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r221592 - stable/8/usr.bin/ar
Author: kaiw Date: Sat May 7 10:35:43 2011 New Revision: 221592 URL: http://svn.freebsd.org/changeset/base/221592 Log: MFC r216719: Document the syntax accepted by the `-M` option. Modified: stable/8/usr.bin/ar/ar.1 Directory Properties: stable/8/usr.bin/ar/ (props changed) Modified: stable/8/usr.bin/ar/ar.1 == --- stable/8/usr.bin/ar/ar.1Sat May 7 10:33:59 2011(r221591) +++ stable/8/usr.bin/ar/ar.1Sat May 7 10:35:43 2011(r221592) @@ -236,6 +236,10 @@ If the archive has a symbol table, it is new contents of the archive. .It Fl M Read and execute MRI librarian commands from standard input. +The commands understood by the +.Nm +utility are described in the section +.Sx MRI Librarian Commands . .It Fl o Preserve the original modification times of members when extracting them. @@ -378,6 +382,117 @@ option was specified. .It Fl z This option is accepted but ignored. .El +.Ss MRI Librarian Commands +If the +.Fl M +option is specified, the +.Nm +utility will read and execute commands from its standard input. +If standard input is a terminal, the +.Nm +utility will display the prompt +.Dq Li AR +before reading a line, and will continue operation even if errors are +encountered. +If standard input is not a terminal, the +.Nm +utility will not display a prompt and will terminate execution on +encountering an error. +.Pp +Each input line contains a single command. +Words in an input line are separated by whitespace characters. +The first word of the line is the command, the remaining words are +the arguments to the command. +The command word may be specified in either case. +Arguments may be separated by commas or blanks. +.Pp +Empty lines are allowed and are ignored. +Long lines are continued by ending them with the +.Dq Li + +character. +.Pp +The +.Dq Li * +and +.Dq Li \; +characters start a comment. +Comments extend till the end of the line. +.Pp +When executing an MRI librarian script the +.Nm +utility works on a temporary copy of an archive. +Changes to the copy are made permanent using the +.Ic save +command. +.Pp +Commands understood by the +.Nm +utility are: +.Bl -tag -width indent +.It Ic addlib Ar archive | Ic addlib Ar archive Pq Ar member Oo Li , Ar member Oc Ns ... +Add the contents of the archive named by argument +.Ar archive +to the current archive. +If specific members are named using the arguments +.Ar member , +then those members are added to the current archive. +If no members are specified, the entire contents of the archive +are added to the current archive. +.It Ic addmod Ar member Oo Li , Ar member Oc Ns ... +Add the files named by arguments +.Ar member +to the current archive. +.It Ic clear +Discard all the contents of the current archive. +.It Ic create Ar archive +Create a new archive named by the argument +.Ar archive , +and makes it the current archive. +If the named archive already exists, it will be overwritten +when the +.Ic save +command is issued. +.It Ic delete Ar module Oo Li , Ar member Oc Ns ... +Delete the modules named by the arguments +.Ar member +from the current archive. +.It Ic directory Ar archive Po Ar member Oo Li , Ar member Oc Ns ... Pc Op Ar outputfile +List each named module in the archive. +The format of the output depends on the verbosity setting set using +the +.Ic verbose +command. +Output is sent to standard output, or to the file specified by +argument +.Ar outputfile . +.It Ic end +Exit successfully from the +.Nm +utility. +Any unsaved changes to the current archive will be discarded. +.It Ic extract Ar member Oo Li , Ar member Oc Ns ... +Extract the members named by the arguments +.Ar member +from the current archive. +.It Ic list +Display the contents of the current archive in verbose style. +.It Ic open Ar archive +Open the archive named by argument +.Ar archive +and make it the current archive. +.It Ic replace Ar member Oo Li , Ar member Oc Ns ... +Replace named members in the current archive with the files specified +by arguments +.Ar member . +The files must be present in the current directory and the named +modules must already exist in the current archive. +.It Ic save +Commit all changes to the current archive. +.It Ic verbose +Toggle the verbosity of the +.Ic directory +command. +.El .Sh EXAMPLES To create a new archive .Pa ex.a @@ -405,6 +520,20 @@ To verbosely list the contents of archiv .Pa ex.a , use: .D1 ar -tv ex.a +.Pp +To create a new archive +.Pa ex.a +containing the files +.Pa ex1.o , +and +.Pa ex2.o , +using MRI librarian commands, use the following script: +.Bd -literal -offset indent +create ex.a * specify the output archive +addmod ex1.o ex2.o * add modules +save* save pending changes +end * exit the utility +.Ed .Sh DIAGNOSTICS .Ex -std .Sh SEE ALSO ___ svn-src-all@freebsd.org mailing list
svn commit: r221594 - head/share/man/man5
Author: kaiw Date: Sat May 7 10:44:08 2011 New Revision: 221594 URL: http://svn.freebsd.org/changeset/base/221594 Log: * Rewrite ar.5 mannual page to better document ar(1) archive format. * Use more standard BSD license. Obtained from:elftoolchain Modified: head/share/man/man5/ar.5 Modified: head/share/man/man5/ar.5 == --- head/share/man/man5/ar.5Sat May 7 10:40:57 2011(r221593) +++ head/share/man/man5/ar.5Sat May 7 10:44:08 2011(r221594) @@ -1,4 +1,4 @@ -.\ Copyright (c) 2007 Joseph Koshy. All rights reserved. +.\ Copyright (c) 2010 Joseph Koshy. All rights reserved. .\ .\ Redistribution and use in source and binary forms, with or without .\ modification, are permitted provided that the following conditions @@ -9,226 +9,319 @@ .\notice, this list of conditions and the following disclaimer in the .\documentation and/or other materials provided with the distribution. .\ -.\ This software is provided by Joseph Koshy ``as is'' and -.\ any express or implied warranties, including, but not limited to, the -.\ implied warranties of merchantability and fitness for a particular purpose -.\ are disclaimed. in no event shall Joseph Koshy be liable -.\ for any direct, indirect, incidental, special, exemplary, or consequential -.\ damages (including, but not limited to, procurement of substitute goods -.\ or services; loss of use, data, or profits; or business interruption) -.\ however caused and on any theory of liability, whether in contract, strict -.\ liability, or tort (including negligence or otherwise) arising in any way -.\ out of the use of this software, even if advised of the possibility of -.\ such damage. +.\ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\ SUCH DAMAGE. .\ .\ $FreeBSD$ .\ -.Dd September 7, 2007 -.Dt AR 5 +.Dd November 28, 2010 .Os +.Dt AR 5 .Sh NAME .Nm ar -.Nd format of archives managed by ar(1) and ranlib(1) +.Nd archive file format for +.Xr ar 1 +and +.Xr ranlib 1 .Sh SYNOPSIS .In ar.h .Sh DESCRIPTION -An archive managed by the +.Xr ar 1 +archives are created and managed by the .Xr ar 1 and .Xr ranlib 1 -utilities is a single file that stores the individual members of the -archive along with metadata for each member. -There are two major variants of the +utilities. +These archives are typically used during program development to +hold libraries of program objects. +An +.Xr ar 1 +archive is contained in a single operating system file. +.Pp +This manual page documents two variants of the .Xr ar 1 -archive format, the BSD variant and the SVR4/GNU variant. -Both variants are described by this manual page. +archive format: the BSD archive format, and the SVR4/GNU archive +format. .Pp -The header file +In both variants the archive file starts with an identifying byte +sequence of the seven ASCII characters +.Sq Li !arch +followed by a ASCII linefeed character +.Po +see the constant +.Dq ARMAG +in the header file .In ar.h -defines constants and structures used to describe the layout -of these archives. -.Ss Archive Layout -.Xr ar 1 -archives start with a string of magic bytes -.Qq !arch\en -(constant -.Dv ARMAG -in header -.In ar.h ) . -The content of the archive follows the magic bytes. -Each member stored in the archive is preceded by a fixed size -archive header that stores file permissions, last modification -time, the owner, and the group of the archived file. -.Pp -Archive headers start at an even byte offset in the archive -file. -If the length of the preceding archive member was odd, then an extra -newline character -.Dq \en -is used as padding. -.Pp -The archive header comprises six fixed-size ASCII strings followed -by a two character trailer (see -.Vt struct ar_hdr -in header file -.In ar.h Ns ): -.Bd -literal -struct ar_hdr { - char ar_name[16]; /* name */ - char ar_date[12]; /* modification time */ - char ar_uid[6]; /* user id */ - char ar_gid[6]; /* group id */ - char ar_mode[8];/* octal file permissions */ - char ar_size[10]; /* size in bytes */ - char ar_fmag[2];/*
svn commit: r221595 - head/lib/libelf
Author: kaiw Date: Sat May 7 11:04:36 2011 New Revision: 221595 URL: http://svn.freebsd.org/changeset/base/221595 Log: For zero-sized sections, set the `d_buf` field of the `Elf_Data` descriptor returned by `elf_rawdata()` to NULL. Obtained from:elftoolchain Modified: head/lib/libelf/elf_data.c Modified: head/lib/libelf/elf_data.c == --- head/lib/libelf/elf_data.c Sat May 7 10:44:08 2011(r221594) +++ head/lib/libelf/elf_data.c Sat May 7 11:04:36 2011(r221595) @@ -225,7 +225,8 @@ elf_rawdata(Elf_Scn *s, Elf_Data *d) if ((d = _libelf_allocate_data(s)) == NULL) return (NULL); - d-d_buf = sh_type == SHT_NOBITS ? NULL : e-e_rawfile + sh_offset; + d-d_buf = (sh_type == SHT_NOBITS || sh_size == 0) ? NULL : + e-e_rawfile + sh_offset; d-d_off = 0; d-d_align = sh_align; d-d_size= sh_size; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r216716 - head/usr.bin/ar
Author: kaiw Date: Sun Dec 26 18:10:39 2010 New Revision: 216716 URL: http://svn.freebsd.org/changeset/base/216716 Log: * Add mention of the `-f`, `-q`, `-S`, and `-V` options in the synopsis section. * Document the `-l`, `-M` and `-S` options. * Improve the text describing the behavior of the `-r` option. * Start a section on standard compliance. * Indicate in the synopsis that the `-S` and `-s` options are mutually exclusive. Obtained from:elftoolchain Modified: head/usr.bin/ar/ar.1 Modified: head/usr.bin/ar/ar.1 == --- head/usr.bin/ar/ar.1Sun Dec 26 17:29:26 2010(r216715) +++ head/usr.bin/ar/ar.1Sun Dec 26 18:10:39 2010(r216716) @@ -34,28 +34,42 @@ .Nm .Fl d .Op Fl T +.Op Fl f .Op Fl j .Op Fl v .Op Fl z .Ar archive -.Ar files ... +.Ar .Nm .Fl m .Op Fl T .Op Fl a Ar position-after .Op Fl b Ar position-before +.Op Fl f .Op Fl i Ar position-before .Op Fl j -.Op Fl s +.Op Fl s | Fl S .Op Fl z .Ar archive -.Ar files ... +.Ar .Nm .Fl p .Op Fl T +.Op Fl f .Op Fl v .Ar archive -.Op Ar files ... +.Op Ar +.Nm +.Fl q +.Op Fl T +.Op Fl c +.Op Fl D +.Op Fl f +.Op Fl s | Fl S +.Op Fl v +.Op Fl z +.Ar archive +.Ar .Nm .Fl r .Op Fl T @@ -63,14 +77,15 @@ .Op Fl b Ar position-before .Op Fl c .Op Fl D +.Op Fl f .Op Fl i Ar position-before .Op Fl j -.Op Fl s +.Op Fl s | Fl S .Op Fl u .Op Fl v .Op Fl z .Ar archive -.Ar files ... +.Ar .Nm .Fl s .Op Fl j @@ -78,19 +93,23 @@ .Ar archive .Nm .Fl t +.Op Fl f .Op Fl T .Op Fl v .Ar archive -.Op Ar files ... +.Op Ar .Nm .Fl x .Op Fl C .Op Fl T +.Op Fl f .Op Fl o .Op Fl u .Op Fl v .Ar archive -.Op Ar files ... +.Op Ar +.Nm +.Fl M .Nm ranlib .Op Fl D .Ar archive ... @@ -141,13 +160,13 @@ When used with option .Fl m this option specifies that the archive members specified by arguments -.Ar files ... +.Ar are moved to after the archive member named by argument .Ar member-after . When used with option .Fl r this option specifies that the files specified by arguments -.Ar files ... +.Ar are added after the archive member named by argument .Ar member-after . .It Fl b Ar member-before @@ -155,13 +174,13 @@ When used with option .Fl m this option specifies that the archive members specified by arguments -.Ar files ... +.Ar are moved to before the archive member named by argument .Ar member-before . When used with option .Fl r this option specifies that the files specified by arguments -.Ar files ... +.Ar are added before the archive member named by argument .Ar member-before . .It Fl c @@ -176,7 +195,7 @@ Prevent extracted files from replacing l in the file system. .It Fl d Delete the members named by arguments -.Ar files ... +.Ar from the archive specified by argument .Ar archive . The archive's symbol table, if present, is updated to reflect @@ -188,7 +207,7 @@ or .Fl q option, insert 0's instead of the real mtime, uid and gid values and 0644 instead of file mode from the members named by arguments -.Ar files ... . +.Ar . This ensures that checksums on the resulting archives are reproducible when member contents are identical. .It Fl f @@ -199,9 +218,13 @@ Synonymous with option .Fl b . .It Fl j This option is accepted but ignored. +.It Fl l +This option is accepted for compatibility with GNU +.Xr ar 1 , +but is ignored. .It Fl m Move archive members specified by arguments -.Ar files ... +.Ar within the archive. If a position has been specified by one of the .Fl a , @@ -214,19 +237,21 @@ If no position has been specified, the s to the end of the archive. If the archive has a symbol table, it is updated to reflect the new contents of the archive. +.It Fl M +Read and execute MRI librarian commands from standard input. .It Fl o Preserve the original modification times of members when extracting them. .It Fl p Write the contents of the specified archive members named by arguments -.Ar files ... +.Ar to standard output. If no members were specified, the contents of all the files in the archive are written in the order they appear in the archive. .It Fl q Append the files specified by arguments -.Ar files ... +.Ar to the archive specified by argument .Ar archive without checking if the files already exist in the archive and @@ -241,14 +266,14 @@ option will update the archive's symbol table. .It Fl r Replace (add) the files specified by arguments -.Ar files ... +.Ar in the archive specified by argument .Ar archive , creating the archive if necessary. -Files that replace existing files do not change the order of files -within the archive. +Replacing existing members will not change the order of members within +the archive. If a file named in arguments -.Ar files ... +.Ar does not exist, existing members in the archive that match that name are not changed. New files are added to the end of the archive unless one of the @@ -271,9
svn commit: r216717 - head/usr.bin/ar
Author: kaiw Date: Sun Dec 26 18:12:13 2010 New Revision: 216717 URL: http://svn.freebsd.org/changeset/base/216717 Log: Improve the description of the `-q` option. Obtained from:elftoolchain Modified: head/usr.bin/ar/ar.1 Modified: head/usr.bin/ar/ar.1 == --- head/usr.bin/ar/ar.1Sun Dec 26 18:10:39 2010(r216716) +++ head/usr.bin/ar/ar.1Sun Dec 26 18:12:13 2010(r216717) @@ -141,10 +141,7 @@ utility can create and manage an archive .Xr ar 5 ) used to speed up link editing operations. If a symbol table is present in an archive, it will be -kept up-to-date by subsequent operations on the archive (excepting -the quick update specified by the -.Fl q -option). +kept up-to-date by subsequent operations on the archive. .Pp The .Nm ranlib @@ -254,16 +251,11 @@ Append the files specified by arguments .Ar to the archive specified by argument .Ar archive -without checking if the files already exist in the archive and -without updating the archive's symbol table. -If the archive file +without checking if the files already exist in the archive. +The archive symbol table will be updated as needed. +If the file specified by the argument .Ar archive -does not already exist, a new archive is created. -However, to be compatible with GNU -.Nm , -option -.Fl q -will update the archive's symbol table. +does not already exist, a new archive will be created. .It Fl r Replace (add) the files specified by arguments .Ar ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r216719 - head/usr.bin/ar
Author: kaiw Date: Sun Dec 26 18:15:32 2010 New Revision: 216719 URL: http://svn.freebsd.org/changeset/base/216719 Log: Document the syntax accepted by the `-M` option. Obtained from:elftoolchain Modified: head/usr.bin/ar/ar.1 Modified: head/usr.bin/ar/ar.1 == --- head/usr.bin/ar/ar.1Sun Dec 26 18:15:18 2010(r216718) +++ head/usr.bin/ar/ar.1Sun Dec 26 18:15:32 2010(r216719) @@ -236,6 +236,10 @@ If the archive has a symbol table, it is new contents of the archive. .It Fl M Read and execute MRI librarian commands from standard input. +The commands understood by the +.Nm +utility are described in the section +.Sx MRI Librarian Commands . .It Fl o Preserve the original modification times of members when extracting them. @@ -378,6 +382,117 @@ option was specified. .It Fl z This option is accepted but ignored. .El +.Ss MRI Librarian Commands +If the +.Fl M +option is specified, the +.Nm +utility will read and execute commands from its standard input. +If standard input is a terminal, the +.Nm +utility will display the prompt +.Dq Li AR +before reading a line, and will continue operation even if errors are +encountered. +If standard input is not a terminal, the +.Nm +utility will not display a prompt and will terminate execution on +encountering an error. +.Pp +Each input line contains a single command. +Words in an input line are separated by whitespace characters. +The first word of the line is the command, the remaining words are +the arguments to the command. +The command word may be specified in either case. +Arguments may be separated by commas or blanks. +.Pp +Empty lines are allowed and are ignored. +Long lines are continued by ending them with the +.Dq Li + +character. +.Pp +The +.Dq Li * +and +.Dq Li \; +characters start a comment. +Comments extend till the end of the line. +.Pp +When executing an MRI librarian script the +.Nm +utility works on a temporary copy of an archive. +Changes to the copy are made permanent using the +.Ic save +command. +.Pp +Commands understood by the +.Nm +utility are: +.Bl -tag -width indent +.It Ic addlib Ar archive | Ic addlib Ar archive Pq Ar member Oo Li , Ar member Oc Ns ... +Add the contents of the archive named by argument +.Ar archive +to the current archive. +If specific members are named using the arguments +.Ar member , +then those members are added to the current archive. +If no members are specified, the entire contents of the archive +are added to the current archive. +.It Ic addmod Ar member Oo Li , Ar member Oc Ns ... +Add the files named by arguments +.Ar member +to the current archive. +.It Ic clear +Discard all the contents of the current archive. +.It Ic create Ar archive +Create a new archive named by the argument +.Ar archive , +and makes it the current archive. +If the named archive already exists, it will be overwritten +when the +.Ic save +command is issued. +.It Ic delete Ar module Oo Li , Ar member Oc Ns ... +Delete the modules named by the arguments +.Ar member +from the current archive. +.It Ic directory Ar archive Po Ar member Oo Li , Ar member Oc Ns ... Pc Op Ar outputfile +List each named module in the archive. +The format of the output depends on the verbosity setting set using +the +.Ic verbose +command. +Output is sent to standard output, or to the file specified by +argument +.Ar outputfile . +.It Ic end +Exit successfully from the +.Nm +utility. +Any unsaved changes to the current archive will be discarded. +.It Ic extract Ar member Oo Li , Ar member Oc Ns ... +Extract the members named by the arguments +.Ar member +from the current archive. +.It Ic list +Display the contents of the current archive in verbose style. +.It Ic open Ar archive +Open the archive named by argument +.Ar archive +and make it the current archive. +.It Ic replace Ar member Oo Li , Ar member Oc Ns ... +Replace named members in the current archive with the files specified +by arguments +.Ar member . +The files must be present in the current directory and the named +modules must already exist in the current archive. +.It Ic save +Commit all changes to the current archive. +.It Ic verbose +Toggle the verbosity of the +.Ic directory +command. +.El .Sh EXAMPLES To create a new archive .Pa ex.a @@ -405,6 +520,20 @@ To verbosely list the contents of archiv .Pa ex.a , use: .D1 ar -tv ex.a +.Pp +To create a new archive +.Pa ex.a +containing the files +.Pa ex1.o , +and +.Pa ex2.o , +using MRI librarian commands, use the following script: +.Bd -literal -offset indent +create ex.a * specify the output archive +addmod ex1.o ex2.o * add modules +save* save pending changes +end * exit the utility +.Ed .Sh DIAGNOSTICS .Ex -std .Sh SEE ALSO ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To
svn commit: r216014 - head/usr.bin/ar
Author: kaiw Date: Sun Nov 28 18:53:57 2010 New Revision: 216014 URL: http://svn.freebsd.org/changeset/base/216014 Log: Add option -D for ranlib(1). When -D is speicified, ranlib(1) will generate a deterministic archive symbol table (i.e. timestamp for the symbol table member header is set to 0). Submitted by: Erik Cederstrand Modified: head/usr.bin/ar/ar.1 head/usr.bin/ar/ar.c Modified: head/usr.bin/ar/ar.1 == --- head/usr.bin/ar/ar.1Sun Nov 28 18:53:29 2010(r216013) +++ head/usr.bin/ar/ar.1Sun Nov 28 18:53:57 2010(r216014) @@ -92,6 +92,7 @@ .Ar archive .Op Ar files ... .Nm ranlib +.Op Fl D .Ar archive ... .Sh DESCRIPTION The Modified: head/usr.bin/ar/ar.c == --- head/usr.bin/ar/ar.cSun Nov 28 18:53:29 2010(r216013) +++ head/usr.bin/ar/ar.cSun Nov 28 18:53:57 2010(r216014) @@ -113,12 +113,15 @@ main(int argc, char **argv) len = strlen(bsdar-progname); if (len = strlen(ranlib) strcmp(bsdar-progname + len - strlen(ranlib), ranlib) == 0) { - while ((opt = getopt_long(argc, argv, tV, longopts, + while ((opt = getopt_long(argc, argv, tDV, longopts, NULL)) != -1) { switch(opt) { case 't': /* Ignored. */ break; + case 'D': + bsdar-options |= AR_D; + break; case 'V': ranlib_version(); break; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r213670 - stable/8/lib/libelf
Author: kaiw Date: Sun Oct 10 12:20:04 2010 New Revision: 213670 URL: http://svn.freebsd.org/changeset/base/213670 Log: MFC r212373: libelf is overly strict about the type and alignment of Elf_Data objects inside one ELF section, which prevents the creation of a ELF section with mixed data types. For example, gcc LTO use libelf to create a .gnu_lto_XXX section that contains integers and a string table, which doesn't work with our libelf implementation. The changes made in this commit include: * Allow Elf_Data type to be different than section type. * Relax Elf_Data alignment check. * Align each Elf_Data by their own alignment instead of section alignment. Modified: stable/8/lib/libelf/elf_update.c Directory Properties: stable/8/lib/libelf/ (props changed) Modified: stable/8/lib/libelf/elf_update.c == --- stable/8/lib/libelf/elf_update.cSun Oct 10 12:18:53 2010 (r213669) +++ stable/8/lib/libelf/elf_update.cSun Oct 10 12:20:04 2010 (r213670) @@ -141,7 +141,7 @@ _libelf_compute_section_extents(Elf *e, /* Compute the section alignment. */ STAILQ_FOREACH(d, s-s_data, d_next) { - if (d-d_type != elftype) { + if (d-d_type ELF_T_LAST) { LIBELF_SET_ERROR(DATA, 0); return (0); } @@ -149,11 +149,7 @@ _libelf_compute_section_extents(Elf *e, LIBELF_SET_ERROR(VERSION, 0); return (0); } - if ((d_align = d-d_align) % sh_align) { - LIBELF_SET_ERROR(LAYOUT, 0); - return (0); - } - if (d_align == 0 || (d_align (d_align - 1))) { + if ((d_align = d-d_align) == 0 || (d_align (d_align - 1))) { LIBELF_SET_ERROR(DATA, 0); return (0); } @@ -168,7 +164,7 @@ _libelf_compute_section_extents(Elf *e, if ((uint64_t) d-d_off + d-d_size scn_size) scn_size = d-d_off + d-d_size; } else { - scn_size = roundup2(scn_size, scn_alignment); + scn_size = roundup2(scn_size, d-d_align); d-d_off = scn_size; scn_size += d-d_size; } @@ -560,8 +556,6 @@ _libelf_write_scn(Elf *e, char *nf, Elf_ elftype = _libelf_xlate_shtype(sh_type); assert(elftype = ELF_T_FIRST elftype = ELF_T_LAST); - msz = _libelf_msize(elftype, ec, e-e_version); - sh_off = s-s_offset; assert(sh_off % _libelf_falign(elftype, ec) == 0); @@ -608,6 +602,8 @@ _libelf_write_scn(Elf *e, char *nf, Elf_ STAILQ_FOREACH(d, s-s_data, d_next) { + msz = _libelf_msize(d-d_type, ec, e-e_version); + if ((uint64_t) rc sh_off + d-d_off) (void) memset(nf + rc, LIBELF_PRIVATE(fillchar), sh_off + d-d_off - rc); @@ -615,13 +611,12 @@ _libelf_write_scn(Elf *e, char *nf, Elf_ rc = sh_off + d-d_off; assert(d-d_buf != NULL); - assert(d-d_type == (Elf_Type) elftype); assert(d-d_version == e-e_version); assert(d-d_size % msz == 0); nobjects = d-d_size / msz; - fsz = _libelf_fsize(elftype, ec, e-e_version, nobjects); + fsz = _libelf_fsize(d-d_type, ec, e-e_version, nobjects); dst.d_buf= nf + rc; dst.d_size = fsz; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r213671 - stable/7/lib/libelf
Author: kaiw Date: Sun Oct 10 12:21:35 2010 New Revision: 213671 URL: http://svn.freebsd.org/changeset/base/213671 Log: MFC r212373: libelf is overly strict about the type and alignment of Elf_Data objects inside one ELF section, which prevents the creation of a ELF section with mixed data types. For example, gcc LTO use libelf to create a .gnu_lto_XXX section that contains integers and a string table, which doesn't work with our libelf implementation. The changes made in this commit include: * Allow Elf_Data type to be different than section type. * Relax Elf_Data alignment check. * Align each Elf_Data by their own alignment instead of section alignment. Modified: stable/7/lib/libelf/elf_update.c Directory Properties: stable/7/lib/libelf/ (props changed) Modified: stable/7/lib/libelf/elf_update.c == --- stable/7/lib/libelf/elf_update.cSun Oct 10 12:20:04 2010 (r213670) +++ stable/7/lib/libelf/elf_update.cSun Oct 10 12:21:35 2010 (r213671) @@ -141,7 +141,7 @@ _libelf_compute_section_extents(Elf *e, /* Compute the section alignment. */ STAILQ_FOREACH(d, s-s_data, d_next) { - if (d-d_type != elftype) { + if (d-d_type ELF_T_LAST) { LIBELF_SET_ERROR(DATA, 0); return (0); } @@ -149,11 +149,7 @@ _libelf_compute_section_extents(Elf *e, LIBELF_SET_ERROR(VERSION, 0); return (0); } - if ((d_align = d-d_align) % sh_align) { - LIBELF_SET_ERROR(LAYOUT, 0); - return (0); - } - if (d_align == 0 || (d_align (d_align - 1))) { + if ((d_align = d-d_align) == 0 || (d_align (d_align - 1))) { LIBELF_SET_ERROR(DATA, 0); return (0); } @@ -168,7 +164,7 @@ _libelf_compute_section_extents(Elf *e, if ((uint64_t) d-d_off + d-d_size scn_size) scn_size = d-d_off + d-d_size; } else { - scn_size = roundup2(scn_size, scn_alignment); + scn_size = roundup2(scn_size, d-d_align); d-d_off = scn_size; scn_size += d-d_size; } @@ -560,8 +556,6 @@ _libelf_write_scn(Elf *e, char *nf, Elf_ elftype = _libelf_xlate_shtype(sh_type); assert(elftype = ELF_T_FIRST elftype = ELF_T_LAST); - msz = _libelf_msize(elftype, ec, e-e_version); - sh_off = s-s_offset; assert(sh_off % _libelf_falign(elftype, ec) == 0); @@ -608,6 +602,8 @@ _libelf_write_scn(Elf *e, char *nf, Elf_ STAILQ_FOREACH(d, s-s_data, d_next) { + msz = _libelf_msize(d-d_type, ec, e-e_version); + if ((uint64_t) rc sh_off + d-d_off) (void) memset(nf + rc, LIBELF_PRIVATE(fillchar), sh_off + d-d_off - rc); @@ -615,13 +611,12 @@ _libelf_write_scn(Elf *e, char *nf, Elf_ rc = sh_off + d-d_off; assert(d-d_buf != NULL); - assert(d-d_type == (Elf_Type) elftype); assert(d-d_version == e-e_version); assert(d-d_size % msz == 0); nobjects = d-d_size / msz; - fsz = _libelf_fsize(elftype, ec, e-e_version, nobjects); + fsz = _libelf_fsize(d-d_type, ec, e-e_version, nobjects); dst.d_buf= nf + rc; dst.d_size = fsz; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
Re: svn commit: r212373 - head/lib/libelf
On Thu, Sep 09, 2010 at 07:54:02PM -0700, Steve Kargl wrote: On Thu, Sep 09, 2010 at 06:51:50PM +, Kai Wang wrote: Author: kaiw Date: Thu Sep 9 18:51:50 2010 New Revision: 212373 URL: http://svn.freebsd.org/changeset/base/212373 Log: libelf is overly strict about the type and alignment of Elf_Data objects inside one ELF section, which prevents the creation of a ELF section with mixed data types. For example, gcc LTO use libelf to create a .gnu_lto_XXX section that contains integers and a string table, which doesn't work with our libelf implementation. The changes made in this commit include: * Allow Elf_Data type to be different than section type. * Relax Elf_Data alignment check. * Align each Elf_Data by their own alignment instead of section alignment. MFC after: 1 month Modified: head/lib/libelf/elf_update.c libelf still doesn't work with GCC. All testsuite failures are of the form collect2: lto-wrapper returned 1 exit status compiler exited with status 1 output is: lto1: error: could not open ELF file: Request error: invalid ELF_C_* argument lto-wrapper: /usr/home/sgk/gcc/obj4x/gcc/testsuite/gfortran/../../gfortran returned 1 exit status collect2: lto-wrapper returned 1 exit status Hi Steve, It seems that your lto1 was compiled with our libelf header but linked to GNU libelf. (I think invalid ELF_C_* argument is GNU libelf error message) Could you please check the value of ldd /path/to/lto1 ? Thanks, Kai ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r212373 - head/lib/libelf
Author: kaiw Date: Thu Sep 9 18:51:50 2010 New Revision: 212373 URL: http://svn.freebsd.org/changeset/base/212373 Log: libelf is overly strict about the type and alignment of Elf_Data objects inside one ELF section, which prevents the creation of a ELF section with mixed data types. For example, gcc LTO use libelf to create a .gnu_lto_XXX section that contains integers and a string table, which doesn't work with our libelf implementation. The changes made in this commit include: * Allow Elf_Data type to be different than section type. * Relax Elf_Data alignment check. * Align each Elf_Data by their own alignment instead of section alignment. MFC after: 1 month Modified: head/lib/libelf/elf_update.c Modified: head/lib/libelf/elf_update.c == --- head/lib/libelf/elf_update.cThu Sep 9 18:51:20 2010 (r212372) +++ head/lib/libelf/elf_update.cThu Sep 9 18:51:50 2010 (r212373) @@ -141,7 +141,7 @@ _libelf_compute_section_extents(Elf *e, /* Compute the section alignment. */ STAILQ_FOREACH(d, s-s_data, d_next) { - if (d-d_type != elftype) { + if (d-d_type ELF_T_LAST) { LIBELF_SET_ERROR(DATA, 0); return (0); } @@ -149,11 +149,7 @@ _libelf_compute_section_extents(Elf *e, LIBELF_SET_ERROR(VERSION, 0); return (0); } - if ((d_align = d-d_align) % sh_align) { - LIBELF_SET_ERROR(LAYOUT, 0); - return (0); - } - if (d_align == 0 || (d_align (d_align - 1))) { + if ((d_align = d-d_align) == 0 || (d_align (d_align - 1))) { LIBELF_SET_ERROR(DATA, 0); return (0); } @@ -168,7 +164,7 @@ _libelf_compute_section_extents(Elf *e, if ((uint64_t) d-d_off + d-d_size scn_size) scn_size = d-d_off + d-d_size; } else { - scn_size = roundup2(scn_size, scn_alignment); + scn_size = roundup2(scn_size, d-d_align); d-d_off = scn_size; scn_size += d-d_size; } @@ -560,8 +556,6 @@ _libelf_write_scn(Elf *e, char *nf, Elf_ elftype = _libelf_xlate_shtype(sh_type); assert(elftype = ELF_T_FIRST elftype = ELF_T_LAST); - msz = _libelf_msize(elftype, ec, e-e_version); - sh_off = s-s_offset; assert(sh_off % _libelf_falign(elftype, ec) == 0); @@ -608,6 +602,8 @@ _libelf_write_scn(Elf *e, char *nf, Elf_ STAILQ_FOREACH(d, s-s_data, d_next) { + msz = _libelf_msize(d-d_type, ec, e-e_version); + if ((uint64_t) rc sh_off + d-d_off) (void) memset(nf + rc, LIBELF_PRIVATE(fillchar), sh_off + d-d_off - rc); @@ -615,13 +611,12 @@ _libelf_write_scn(Elf *e, char *nf, Elf_ rc = sh_off + d-d_off; assert(d-d_buf != NULL); - assert(d-d_type == (Elf_Type) elftype); assert(d-d_version == e-e_version); assert(d-d_size % msz == 0); nobjects = d-d_size / msz; - fsz = _libelf_fsize(elftype, ec, e-e_version, nobjects); + fsz = _libelf_fsize(d-d_type, ec, e-e_version, nobjects); dst.d_buf= nf + rc; dst.d_size = fsz; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r212196 - stable/8/lib/libelf
Author: kaiw Date: Sat Sep 4 11:50:17 2010 New Revision: 212196 URL: http://svn.freebsd.org/changeset/base/212196 Log: MFC r210321: Remove a superfluous comment. Modified: stable/8/lib/libelf/elf_update.c Directory Properties: stable/8/lib/libelf/ (props changed) Modified: stable/8/lib/libelf/elf_update.c == --- stable/8/lib/libelf/elf_update.cSat Sep 4 08:42:19 2010 (r212195) +++ stable/8/lib/libelf/elf_update.cSat Sep 4 11:50:17 2010 (r212196) @@ -297,7 +297,6 @@ _libelf_resync_sections(Elf *e, off_t rc else sh_type = s-s_shdr.s_shdr64.sh_type; - /* XXX Do we need the 'size' field of an SHT_NOBITS section */ if (sh_type == SHT_NOBITS || sh_type == SHT_NULL) continue; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r212197 - stable/7/lib/libelf
Author: kaiw Date: Sat Sep 4 11:50:23 2010 New Revision: 212197 URL: http://svn.freebsd.org/changeset/base/212197 Log: MFC r210321: Remove a superfluous comment. Modified: stable/7/lib/libelf/elf_update.c Directory Properties: stable/7/lib/libelf/ (props changed) Modified: stable/7/lib/libelf/elf_update.c == --- stable/7/lib/libelf/elf_update.cSat Sep 4 11:50:17 2010 (r212196) +++ stable/7/lib/libelf/elf_update.cSat Sep 4 11:50:23 2010 (r212197) @@ -297,7 +297,6 @@ _libelf_resync_sections(Elf *e, off_t rc else sh_type = s-s_shdr.s_shdr64.sh_type; - /* XXX Do we need the 'size' field of an SHT_NOBITS section */ if (sh_type == SHT_NOBITS || sh_type == SHT_NULL) continue; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r212198 - in stable/8: cddl/contrib/opensolaris/tools/ctf/cvt lib/libelf
Author: kaiw Date: Sat Sep 4 12:06:02 2010 New Revision: 212198 URL: http://svn.freebsd.org/changeset/base/212198 Log: MFC r210324, r210438. r210324: - 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. - 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. r210438: (np) Catch up with r210324. d_buf will be NULL for SHT_NOBITS sections, do not attempt to copy from it in that case. Modified: stable/8/cddl/contrib/opensolaris/tools/ctf/cvt/output.c stable/8/lib/libelf/elf_data.c stable/8/lib/libelf/elf_getdata.3 Directory Properties: stable/8/cddl/contrib/opensolaris/ (props changed) stable/8/lib/libelf/ (props changed) Modified: stable/8/cddl/contrib/opensolaris/tools/ctf/cvt/output.c == --- stable/8/cddl/contrib/opensolaris/tools/ctf/cvt/output.cSat Sep 4 11:50:23 2010(r212197) +++ stable/8/cddl/contrib/opensolaris/tools/ctf/cvt/output.cSat Sep 4 12:06:02 2010(r212198) @@ -644,7 +644,7 @@ write_file(Elf *src, const char *srcname } #if !defined(sun) - if (ddata-d_buf == NULL) { + if (ddata-d_buf == NULL sdata-d_buf != NULL) { ddata-d_buf = xmalloc(shdr.sh_size); bcopy(sdata-d_buf, ddata-d_buf, shdr.sh_size); } Modified: stable/8/lib/libelf/elf_data.c == --- stable/8/lib/libelf/elf_data.c Sat Sep 4 11:50:23 2010 (r212197) +++ stable/8/lib/libelf/elf_data.c Sat Sep 4 12:06:02 2010 (r212198) @@ -39,7 +39,6 @@ Elf_Data * elf_getdata(Elf_Scn *s, Elf_Data *d) { Elf *e; - char *dst; size_t fsz, msz, count; int elfclass, elftype; unsigned int sh_type; @@ -79,20 +78,22 @@ elf_getdata(Elf_Scn *s, Elf_Data *d) sh_align = s-s_shdr.s_shdr64.sh_addralign; } + if (sh_type == SHT_NULL) + return (NULL); + if ((elftype = _libelf_xlate_shtype(sh_type)) ELF_T_FIRST || - elftype ELF_T_LAST || - sh_offset + sh_size (uint64_t) e-e_rawsize) { + elftype ELF_T_LAST || (sh_type != SHT_NOBITS + sh_offset + sh_size (uint64_t) e-e_rawsize)) { LIBELF_SET_ERROR(SECTION, 0); return (NULL); } - if ((fsz = (elfclass == ELFCLASS32 ? elf32_fsize : elf64_fsize)(elftype, -(size_t) 1, e-e_version)) == 0) { + if ((fsz = (elfclass == ELFCLASS32 ? elf32_fsize : elf64_fsize) +(elftype, (size_t) 1, e-e_version)) == 0) { LIBELF_SET_ERROR(UNIMPL, 0); return (NULL); } - if (sh_size % fsz) { LIBELF_SET_ERROR(SECTION, 0); return (NULL); @@ -104,21 +105,25 @@ elf_getdata(Elf_Scn *s, Elf_Data *d) assert(msz 0); - if ((dst = malloc(msz*count)) == NULL) { - LIBELF_SET_ERROR(RESOURCE, 0); - return (NULL); - } - if ((d = _libelf_allocate_data(s)) == NULL) return (NULL); - d-d_buf = dst; + d-d_buf = NULL; d-d_off = 0; d-d_align = sh_align; d-d_size= msz * count; d-d_type= elftype; d-d_version = e-e_version; + if (sh_type == SHT_NOBITS) + return (d); + + if ((d-d_buf = malloc(msz*count)) == NULL) { + (void) _libelf_release_data(d); + LIBELF_SET_ERROR(RESOURCE, 0); + return (NULL); + } + d-d_flags |= LIBELF_F_MALLOCED; STAILQ_INSERT_TAIL(s-s_data, d, d_next); @@ -149,14 +154,10 @@ elf_newdata(Elf_Scn *s) if (elf_getdata(s, NULL) == NULL) return (NULL); - if ((d = malloc(sizeof(Elf_Data))) == NULL) { - LIBELF_SET_ERROR(RESOURCE, errno); + if ((d = _libelf_allocate_data(s)) == NULL) return (NULL); - } STAILQ_INSERT_TAIL(s-s_data, d, d_next); - d-d_flags = 0; - d-d_scn = s; d-d_align = 1; d-d_buf = NULL; @@ -180,6 +181,7 @@ elf_rawdata(Elf_Scn *s, Elf_Data *d) { Elf *e; int elf_class; + uint32_t sh_type; uint64_t sh_align, sh_offset, sh_size; if (s == NULL || (e = s-s_elf) == NULL || @@ -199,19 +201,24 @@ elf_rawdata(Elf_Scn *s, Elf_Data *d) assert(elf_class == ELFCLASS32 || elf_class == ELFCLASS64); if (elf_class == ELFCLASS32) { +
svn commit: r212199 - in stable/7: cddl/contrib/opensolaris/tools/ctf/cvt lib/libelf
Author: kaiw Date: Sat Sep 4 12:06:09 2010 New Revision: 212199 URL: http://svn.freebsd.org/changeset/base/212199 Log: MFC r210324, r210438. r210324: - 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. - 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. r210438: (np) Catch up with r210324. d_buf will be NULL for SHT_NOBITS sections, do not attempt to copy from it in that case. Modified: stable/7/cddl/contrib/opensolaris/tools/ctf/cvt/output.c stable/7/lib/libelf/elf_data.c stable/7/lib/libelf/elf_getdata.3 Directory Properties: stable/7/cddl/contrib/opensolaris/ (props changed) stable/7/lib/libelf/ (props changed) Modified: stable/7/cddl/contrib/opensolaris/tools/ctf/cvt/output.c == --- stable/7/cddl/contrib/opensolaris/tools/ctf/cvt/output.cSat Sep 4 12:06:02 2010(r212198) +++ stable/7/cddl/contrib/opensolaris/tools/ctf/cvt/output.cSat Sep 4 12:06:09 2010(r212199) @@ -644,7 +644,7 @@ write_file(Elf *src, const char *srcname } #if !defined(sun) - if (ddata-d_buf == NULL) { + if (ddata-d_buf == NULL sdata-d_buf != NULL) { ddata-d_buf = xmalloc(shdr.sh_size); bcopy(sdata-d_buf, ddata-d_buf, shdr.sh_size); } Modified: stable/7/lib/libelf/elf_data.c == --- stable/7/lib/libelf/elf_data.c Sat Sep 4 12:06:02 2010 (r212198) +++ stable/7/lib/libelf/elf_data.c Sat Sep 4 12:06:09 2010 (r212199) @@ -39,7 +39,6 @@ Elf_Data * elf_getdata(Elf_Scn *s, Elf_Data *d) { Elf *e; - char *dst; size_t fsz, msz, count; int elfclass, elftype; unsigned int sh_type; @@ -79,20 +78,22 @@ elf_getdata(Elf_Scn *s, Elf_Data *d) sh_align = s-s_shdr.s_shdr64.sh_addralign; } + if (sh_type == SHT_NULL) + return (NULL); + if ((elftype = _libelf_xlate_shtype(sh_type)) ELF_T_FIRST || - elftype ELF_T_LAST || - sh_offset + sh_size (uint64_t) e-e_rawsize) { + elftype ELF_T_LAST || (sh_type != SHT_NOBITS + sh_offset + sh_size (uint64_t) e-e_rawsize)) { LIBELF_SET_ERROR(SECTION, 0); return (NULL); } - if ((fsz = (elfclass == ELFCLASS32 ? elf32_fsize : elf64_fsize)(elftype, -(size_t) 1, e-e_version)) == 0) { + if ((fsz = (elfclass == ELFCLASS32 ? elf32_fsize : elf64_fsize) +(elftype, (size_t) 1, e-e_version)) == 0) { LIBELF_SET_ERROR(UNIMPL, 0); return (NULL); } - if (sh_size % fsz) { LIBELF_SET_ERROR(SECTION, 0); return (NULL); @@ -104,21 +105,25 @@ elf_getdata(Elf_Scn *s, Elf_Data *d) assert(msz 0); - if ((dst = malloc(msz*count)) == NULL) { - LIBELF_SET_ERROR(RESOURCE, 0); - return (NULL); - } - if ((d = _libelf_allocate_data(s)) == NULL) return (NULL); - d-d_buf = dst; + d-d_buf = NULL; d-d_off = 0; d-d_align = sh_align; d-d_size= msz * count; d-d_type= elftype; d-d_version = e-e_version; + if (sh_type == SHT_NOBITS) + return (d); + + if ((d-d_buf = malloc(msz*count)) == NULL) { + (void) _libelf_release_data(d); + LIBELF_SET_ERROR(RESOURCE, 0); + return (NULL); + } + d-d_flags |= LIBELF_F_MALLOCED; STAILQ_INSERT_TAIL(s-s_data, d, d_next); @@ -149,14 +154,10 @@ elf_newdata(Elf_Scn *s) if (elf_getdata(s, NULL) == NULL) return (NULL); - if ((d = malloc(sizeof(Elf_Data))) == NULL) { - LIBELF_SET_ERROR(RESOURCE, errno); + if ((d = _libelf_allocate_data(s)) == NULL) return (NULL); - } STAILQ_INSERT_TAIL(s-s_data, d, d_next); - d-d_flags = 0; - d-d_scn = s; d-d_align = 1; d-d_buf = NULL; @@ -180,6 +181,7 @@ elf_rawdata(Elf_Scn *s, Elf_Data *d) { Elf *e; int elf_class; + uint32_t sh_type; uint64_t sh_align, sh_offset, sh_size; if (s == NULL || (e = s-s_elf) == NULL || @@ -199,19 +201,24 @@ elf_rawdata(Elf_Scn *s, Elf_Data *d) assert(elf_class == ELFCLASS32 || elf_class == ELFCLASS64); if (elf_class == ELFCLASS32) { +
svn commit: r212200 - stable/8/lib/libelf
Author: kaiw Date: Sat Sep 4 12:19:19 2010 New Revision: 212200 URL: http://svn.freebsd.org/changeset/base/212200 Log: MFC r210325,r210326,r210328,r210349 r210325: Bug fix: when updating headers using the gelf_update_*() functions, the appropriate `dirty' bit needs to be set for both the Elf32 and Elf64 case. r210326: Improve compatibility with other implementations of the ELF(3) API: when an output file has no program headers, set the 'e_phentsize' field of the ELF executable header to zero. r210328: Bug fix: permit the creation of zero-sized sections. r210349: Remove a redundant word. Modified: stable/8/lib/libelf/elf.3 stable/8/lib/libelf/elf_update.c stable/8/lib/libelf/gelf_ehdr.c stable/8/lib/libelf/gelf_phdr.c stable/8/lib/libelf/gelf_shdr.c Directory Properties: stable/8/lib/libelf/ (props changed) Modified: stable/8/lib/libelf/elf.3 == --- stable/8/lib/libelf/elf.3 Sat Sep 4 12:06:09 2010(r212199) +++ stable/8/lib/libelf/elf.3 Sat Sep 4 12:19:19 2010(r212200) @@ -36,8 +36,8 @@ .Sh DESCRIPTION The .Lb libelf -library provides functions that allow an application to read and -manipulate ELF object files, and to read +provides functions that allow an application to read and manipulate +ELF object files, and to read .Xr ar 1 archives. The library allows the manipulation of ELF objects in a byte ordering Modified: stable/8/lib/libelf/elf_update.c == --- stable/8/lib/libelf/elf_update.cSat Sep 4 12:06:09 2010 (r212199) +++ stable/8/lib/libelf/elf_update.cSat Sep 4 12:19:19 2010 (r212200) @@ -422,8 +422,8 @@ _libelf_resync_elf(Elf *e) (E)-e_ident[EI_VERSION] = (V); \ (E)-e_ehsize = _libelf_fsize(ELF_T_EHDR, (EC), (V),\ (size_t) 1);\ - (E)-e_phentsize = _libelf_fsize(ELF_T_PHDR, (EC), (V), \ - (size_t) 1);\ + (E)-e_phentsize = (phnum == 0) ? 0 : _libelf_fsize(\ + ELF_T_PHDR, (EC), (V), (size_t) 1); \ (E)-e_shentsize = _libelf_fsize(ELF_T_SHDR, (EC), (V), \ (size_t) 1);\ } while (0) @@ -534,22 +534,24 @@ _libelf_write_scn(Elf *e, char *nf, Elf_ int ec; size_t fsz, msz, nobjects; uint32_t sh_type; - uint64_t sh_off; + uint64_t sh_off, sh_size; int elftype; Elf_Data *d, dst; - if ((ec = e-e_class) == ELFCLASS32) + if ((ec = e-e_class) == ELFCLASS32) { sh_type = s-s_shdr.s_shdr32.sh_type; - else + sh_size = (uint64_t) s-s_shdr.s_shdr32.sh_size; + } else { sh_type = s-s_shdr.s_shdr64.sh_type; + sh_size = s-s_shdr.s_shdr64.sh_size; + } /* * Ignore sections that do not allocate space in the file. */ - if (sh_type == SHT_NOBITS || sh_type == SHT_NULL) + if (sh_type == SHT_NOBITS || sh_type == SHT_NULL || sh_size == 0) return (rc); - elftype = _libelf_xlate_shtype(sh_type); assert(elftype = ELF_T_FIRST elftype = ELF_T_LAST); Modified: stable/8/lib/libelf/gelf_ehdr.c == --- stable/8/lib/libelf/gelf_ehdr.c Sat Sep 4 12:06:09 2010 (r212199) +++ stable/8/lib/libelf/gelf_ehdr.c Sat Sep 4 12:19:19 2010 (r212200) @@ -137,6 +137,8 @@ gelf_update_ehdr(Elf *e, GElf_Ehdr *s) if ((ehdr = _libelf_ehdr(e, ec, 0)) == NULL) return (0); + (void) elf_flagehdr(e, ELF_C_SET, ELF_F_DIRTY); + if (ec == ELFCLASS64) { eh64 = (Elf64_Ehdr *) ehdr; *eh64 = *s; @@ -161,7 +163,5 @@ gelf_update_ehdr(Elf *e, GElf_Ehdr *s) eh32-e_shnum = s-e_shnum; eh32-e_shstrndx = s-e_shstrndx; - (void) elf_flagehdr(e, ELF_C_SET, ELF_F_DIRTY); - return (1); } Modified: stable/8/lib/libelf/gelf_phdr.c == --- stable/8/lib/libelf/gelf_phdr.c Sat Sep 4 12:06:09 2010 (r212199) +++ stable/8/lib/libelf/gelf_phdr.c Sat Sep 4 12:19:19 2010 (r212200) @@ -155,6 +155,8 @@ gelf_update_phdr(Elf *e, int ndx, GElf_P return (0); } + (void) elf_flagphdr(e, ELF_C_SET, ELF_F_DIRTY); + if (ec == ELFCLASS64) { ph64 = e-e_u.e_elf.e_phdr.e_phdr64 + ndx; *ph64 = *s; @@ -172,7 +174,5 @@ gelf_update_phdr(Elf *e, int ndx, GElf_P LIBELF_COPY_U32(ph32, s, p_memsz);
svn commit: r212203 - stable/7/lib/libelf
Author: kaiw Date: Sat Sep 4 12:40:16 2010 New Revision: 212203 URL: http://svn.freebsd.org/changeset/base/212203 Log: MFC r210329,r210330,r210347. r210329: Use unistd.h to declare the prototype for ftruncate(). r210330: Allow an application that updates only the ELF Ehdr to work. r210347: Fix a memory leak. Modified: stable/7/lib/libelf/_libelf.h stable/7/lib/libelf/elf_begin.c stable/7/lib/libelf/elf_scn.c stable/7/lib/libelf/elf_update.c Directory Properties: stable/7/lib/libelf/ (props changed) Modified: stable/7/lib/libelf/_libelf.h == --- stable/7/lib/libelf/_libelf.h Sat Sep 4 12:40:06 2010 (r212202) +++ stable/7/lib/libelf/_libelf.h Sat Sep 4 12:40:16 2010 (r212203) @@ -176,6 +176,7 @@ void(*_libelf_get_translator(Elf_Type _ void *_libelf_getphdr(Elf *_e, int _elfclass); void *_libelf_getshdr(Elf_Scn *_scn, int _elfclass); void _libelf_init_elf(Elf *_e, Elf_Kind _kind); +int_libelf_load_scn(Elf *e, void *ehdr); int_libelf_malign(Elf_Type _t, int _elfclass); size_t _libelf_msize(Elf_Type _t, int _elfclass, unsigned int _version); void *_libelf_newphdr(Elf *_e, int _elfclass, size_t _count); Modified: stable/7/lib/libelf/elf_begin.c == --- stable/7/lib/libelf/elf_begin.c Sat Sep 4 12:40:06 2010 (r212202) +++ stable/7/lib/libelf/elf_begin.c Sat Sep 4 12:40:16 2010 (r212203) @@ -35,6 +35,7 @@ __FBSDID($FreeBSD$); #include ar.h #include ctype.h #include libelf.h +#include unistd.h #include _libelf.h Modified: stable/7/lib/libelf/elf_scn.c == --- stable/7/lib/libelf/elf_scn.c Sat Sep 4 12:40:06 2010 (r212202) +++ stable/7/lib/libelf/elf_scn.c Sat Sep 4 12:40:16 2010 (r212203) @@ -38,7 +38,7 @@ __FBSDID($FreeBSD$); /* * Load an ELF section table and create a list of Elf_Scn structures. */ -static int +int _libelf_load_scn(Elf *e, void *ehdr) { int ec, swapbytes; Modified: stable/7/lib/libelf/elf_update.c == --- stable/7/lib/libelf/elf_update.cSat Sep 4 12:40:06 2010 (r212202) +++ stable/7/lib/libelf/elf_update.cSat Sep 4 12:40:16 2010 (r212203) @@ -472,6 +472,11 @@ _libelf_resync_elf(Elf *e) * file. */ + if (e-e_cmd != ELF_C_WRITE + (e-e_flags LIBELF_F_SHDRS_LOADED) == 0 + _libelf_load_scn(e, ehdr) == 0) + return ((off_t) -1); + if ((rc = _libelf_resync_sections(e, rc)) 0) return ((off_t) -1); @@ -726,14 +731,9 @@ _libelf_write_elf(Elf *e, off_t newsize) assert(phoff % _libelf_falign(ELF_T_PHDR, ec) == 0); assert(fsz 0); + src.d_buf = _libelf_getphdr(e, ec); src.d_version = dst.d_version = e-e_version; src.d_type = ELF_T_PHDR; - - if (ec == ELFCLASS32) - src.d_buf = e-e_u.e_elf.e_phdr.e_phdr32; - else - src.d_buf = e-e_u.e_elf.e_phdr.e_phdr64; - src.d_size = phnum * _libelf_msize(ELF_T_PHDR, ec, e-e_version); @@ -855,11 +855,13 @@ _libelf_write_elf(Elf *e, off_t newsize) e-e_u.e_elf.e_phdr.e_phdr64 = NULL; } + free(newfile); + return (rc); error: - if (newfile) - free(newfile); + free(newfile); + return ((off_t) -1); } ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r212204 - stable/8/lib/libelf
Author: kaiw Date: Sat Sep 4 12:52:44 2010 New Revision: 212204 URL: http://svn.freebsd.org/changeset/base/212204 Log: MFC r210344,r210345,r210348. r210344: Avoid switching between unsigned char and char in the C code generated from libelf_convert.m4. r210345: * Deprecate `elf_getshnum()`, `elf_getphnum()` and `elf_getshstrndx()` in favour of `elf_getshdrnum()`, `elf_getphdrnum()` and `elf_getshdrstrndx()` respectively. * Add new manual pages for `elf_getshdrstrndx()`, `elf_getphdrnum()` and `elf_getshdrnum()`. * Add a deprecation warning for `elf_getshstrndx()`, `elf_getphnum()` and `elf_getshnum()`. r210348: Move helper functions `_libelf_ar_get_{name,number,string}()` and `_libelf_ar_open()` to a new compilation unit libelf_ar_util.c to break the circular dependency between elf_memory.o and libelf_ar.o. Added: stable/8/lib/libelf/elf_getphdrnum.3 - copied unchanged from r210345, head/lib/libelf/elf_getphdrnum.3 stable/8/lib/libelf/elf_getshdrnum.3 - copied unchanged from r210345, head/lib/libelf/elf_getshdrnum.3 stable/8/lib/libelf/elf_getshdrstrndx.3 - copied unchanged from r210345, head/lib/libelf/elf_getshdrstrndx.3 stable/8/lib/libelf/libelf_ar_util.c - copied unchanged from r210348, head/lib/libelf/libelf_ar_util.c Modified: stable/8/lib/libelf/Makefile stable/8/lib/libelf/Version.map stable/8/lib/libelf/_libelf.h stable/8/lib/libelf/elf_getphnum.3 stable/8/lib/libelf/elf_getshnum.3 stable/8/lib/libelf/elf_getshstrndx.3 stable/8/lib/libelf/elf_phnum.c stable/8/lib/libelf/elf_shnum.c stable/8/lib/libelf/elf_shstrndx.c stable/8/lib/libelf/libelf.h stable/8/lib/libelf/libelf_ar.c stable/8/lib/libelf/libelf_convert.m4 Directory Properties: stable/8/lib/libelf/ (props changed) Modified: stable/8/lib/libelf/Makefile == --- stable/8/lib/libelf/MakefileSat Sep 4 12:40:16 2010 (r212203) +++ stable/8/lib/libelf/MakefileSat Sep 4 12:52:44 2010 (r212204) @@ -44,6 +44,7 @@ SRCS= elf_begin.c \ libelf_align.c \ libelf_allocate.c \ libelf_ar.c \ + libelf_ar_util.c\ libelf_checksum.c \ libelf_data.c \ libelf_ehdr.c \ @@ -65,7 +66,8 @@ WARNS?= 6 MAN= elf.3 \ elf_begin.3 \ elf_cntl.3 \ - elf_end.3 elf_errmsg.3 \ + elf_end.3 \ + elf_errmsg.3\ elf_fill.3 \ elf_flagdata.3 \ elf_getarhdr.3 \ @@ -74,8 +76,11 @@ MAN= elf.3 \ elf_getdata.3 \ elf_getident.3 \ elf_getscn.3\ + elf_getphdrnum.3\ elf_getphnum.3 \ + elf_getshdrnum.3\ elf_getshnum.3 \ + elf_getshdrstrndx.3 \ elf_getshstrndx.3 \ elf_hash.3 \ elf_kind.3 \ Modified: stable/8/lib/libelf/Version.map == --- stable/8/lib/libelf/Version.map Sat Sep 4 12:40:16 2010 (r212203) +++ stable/8/lib/libelf/Version.map Sat Sep 4 12:52:44 2010 (r212204) @@ -39,8 +39,11 @@ global: elf_getdata; elf_getident; elf_getscn; + elf_getphdrnum; elf_getphnum; + elf_getshdrnum; elf_getshnum; + elf_getshdrstrndx; elf_getshstrndx; elf_hash; elf_kind; Modified: stable/8/lib/libelf/_libelf.h == --- stable/8/lib/libelf/_libelf.h Sat Sep 4 12:40:16 2010 (r212203) +++ stable/8/lib/libelf/_libelf.h Sat Sep 4 12:52:44 2010 (r212204) @@ -165,6 +165,10 @@ Elf_Scn
svn commit: r212205 - stable/7/lib/libelf
Author: kaiw Date: Sat Sep 4 12:52:51 2010 New Revision: 212205 URL: http://svn.freebsd.org/changeset/base/212205 Log: MFC r210344,r210345,r210348. r210344: Avoid switching between unsigned char and char in the C code generated from libelf_convert.m4. r210345: * Deprecate `elf_getshnum()`, `elf_getphnum()` and `elf_getshstrndx()` in favour of `elf_getshdrnum()`, `elf_getphdrnum()` and `elf_getshdrstrndx()` respectively. * Add new manual pages for `elf_getshdrstrndx()`, `elf_getphdrnum()` and `elf_getshdrnum()`. * Add a deprecation warning for `elf_getshstrndx()`, `elf_getphnum()` and `elf_getshnum()`. r210348: Move helper functions `_libelf_ar_get_{name,number,string}()` and `_libelf_ar_open()` to a new compilation unit libelf_ar_util.c to break the circular dependency between elf_memory.o and libelf_ar.o. Added: stable/7/lib/libelf/elf_getphdrnum.3 - copied unchanged from r210345, head/lib/libelf/elf_getphdrnum.3 stable/7/lib/libelf/elf_getshdrnum.3 - copied unchanged from r210345, head/lib/libelf/elf_getshdrnum.3 stable/7/lib/libelf/elf_getshdrstrndx.3 - copied unchanged from r210345, head/lib/libelf/elf_getshdrstrndx.3 stable/7/lib/libelf/libelf_ar_util.c - copied unchanged from r210348, head/lib/libelf/libelf_ar_util.c Modified: stable/7/lib/libelf/Makefile stable/7/lib/libelf/Version.map stable/7/lib/libelf/_libelf.h stable/7/lib/libelf/elf_getphnum.3 stable/7/lib/libelf/elf_getshnum.3 stable/7/lib/libelf/elf_getshstrndx.3 stable/7/lib/libelf/elf_phnum.c stable/7/lib/libelf/elf_shnum.c stable/7/lib/libelf/elf_shstrndx.c stable/7/lib/libelf/libelf.h stable/7/lib/libelf/libelf_ar.c stable/7/lib/libelf/libelf_convert.m4 Directory Properties: stable/7/lib/libelf/ (props changed) Modified: stable/7/lib/libelf/Makefile == --- stable/7/lib/libelf/MakefileSat Sep 4 12:52:44 2010 (r212204) +++ stable/7/lib/libelf/MakefileSat Sep 4 12:52:51 2010 (r212205) @@ -44,6 +44,7 @@ SRCS= elf_begin.c \ libelf_align.c \ libelf_allocate.c \ libelf_ar.c \ + libelf_ar_util.c\ libelf_checksum.c \ libelf_data.c \ libelf_ehdr.c \ @@ -65,7 +66,8 @@ WARNS?= 6 MAN= elf.3 \ elf_begin.3 \ elf_cntl.3 \ - elf_end.3 elf_errmsg.3 \ + elf_end.3 \ + elf_errmsg.3\ elf_fill.3 \ elf_flagdata.3 \ elf_getarhdr.3 \ @@ -74,8 +76,11 @@ MAN= elf.3 \ elf_getdata.3 \ elf_getident.3 \ elf_getscn.3\ + elf_getphdrnum.3\ elf_getphnum.3 \ + elf_getshdrnum.3\ elf_getshnum.3 \ + elf_getshdrstrndx.3 \ elf_getshstrndx.3 \ elf_hash.3 \ elf_kind.3 \ Modified: stable/7/lib/libelf/Version.map == --- stable/7/lib/libelf/Version.map Sat Sep 4 12:52:44 2010 (r212204) +++ stable/7/lib/libelf/Version.map Sat Sep 4 12:52:51 2010 (r212205) @@ -39,8 +39,11 @@ global: elf_getdata; elf_getident; elf_getscn; + elf_getphdrnum; elf_getphnum; + elf_getshdrnum; elf_getshnum; + elf_getshdrstrndx; elf_getshstrndx; elf_hash; elf_kind; Modified: stable/7/lib/libelf/_libelf.h == --- stable/7/lib/libelf/_libelf.h Sat Sep 4 12:52:44 2010 (r212204) +++ stable/7/lib/libelf/_libelf.h Sat Sep 4 12:52:51 2010 (r212205) @@ -165,6 +165,10 @@ Elf_Scn
svn commit: r212206 - stable/8/lib/libelf
Author: kaiw Date: Sat Sep 4 13:00:22 2010 New Revision: 212206 URL: http://svn.freebsd.org/changeset/base/212206 Log: MFC r210351-r210353,r211192. r210351: * Note that ar(1) archives may also be opened using `elf_memory(3)`. * Ignore the passed in value of the `fd` argument for ar(1) archives opened with elf_memory(3). r210352: Add a cross-reference to `elf_rawfile(3)`. r210353: * Remove a superfluous error description. * Document an additional error that may be returned: `ELF_E_ARCHIVE`. r211192: Add translation support for section type SHT_SUNW_dof. Modified: stable/8/lib/libelf/elf_begin.3 stable/8/lib/libelf/elf_begin.c stable/8/lib/libelf/elf_getdata.3 stable/8/lib/libelf/libelf_data.c Directory Properties: stable/8/lib/libelf/ (props changed) Modified: stable/8/lib/libelf/elf_begin.3 == --- stable/8/lib/libelf/elf_begin.3 Sat Sep 4 12:52:51 2010 (r212205) +++ stable/8/lib/libelf/elf_begin.3 Sat Sep 4 13:00:22 2010 (r212206) @@ -23,7 +23,7 @@ .\ .\ $FreeBSD$ .\ -.Dd June 21, 2006 +.Dd June 20, 2010 .Dt ELF_BEGIN 3 .Os .Sh NAME @@ -163,7 +163,9 @@ archive may be opened in read mode (with set to .Dv ELF_C_READ ) using -.Fn elf_begin . +.Fn elf_begin +or +.Fn elf_memory . The returned ELF descriptor can be passed into to subsequent calls to .Fn elf_begin @@ -222,6 +224,10 @@ Function can fail with the following errors: .Pp .Bl -tag -width [ELF_E_RESOURCE] +.It Bq Er ELF_E_ARCHIVE +The archive denoted by argument +.Ar elf +could not be parsed. .It Bq Er ELF_E_ARGUMENT An unrecognized value was specified in argument .Ar cmd . @@ -245,12 +251,6 @@ differs from the value specified when EL .Ar elf was created. .It Bq Er ELF_E_ARGUMENT -Argument -.Ar elf -was not a descriptor for an -.Xr ar 1 -archive. -.It Bq Er ELF_E_ARGUMENT An .Xr ar 1 archive was opened with with Modified: stable/8/lib/libelf/elf_begin.c == --- stable/8/lib/libelf/elf_begin.c Sat Sep 4 12:52:51 2010 (r212205) +++ stable/8/lib/libelf/elf_begin.c Sat Sep 4 13:00:22 2010 (r212206) @@ -131,13 +131,15 @@ elf_begin(int fd, Elf_Cmd c, Elf *a) case ELF_C_READ: /* * Descriptor `a' could be for a regular ELF file, or -* for an ar(1) archive. +* for an ar(1) archive. If descriptor `a' was opened +* using a valid file descriptor, we need to check if +* the passed in `fd' value matches the original one. */ - if (a (a-e_fd != fd || c != a-e_cmd)) { + if (a + ((a-e_fd != -1 a-e_fd != fd) || c != a-e_cmd)) { LIBELF_SET_ERROR(ARGUMENT, 0); return (NULL); } - break; default: @@ -149,7 +151,7 @@ elf_begin(int fd, Elf_Cmd c, Elf *a) if (a == NULL) e = _libelf_open_object(fd, c); else if (a-e_kind == ELF_K_AR) - e = _libelf_ar_open_member(fd, c, a); + e = _libelf_ar_open_member(a-e_fd, c, a); else (e = a)-e_activations++; Modified: stable/8/lib/libelf/elf_getdata.3 == --- stable/8/lib/libelf/elf_getdata.3 Sat Sep 4 12:52:51 2010 (r212205) +++ stable/8/lib/libelf/elf_getdata.3 Sat Sep 4 13:00:22 2010 (r212206) @@ -1,4 +1,4 @@ -.\ Copyright (c) 2006,2008 Joseph Koshy. All rights reserved. +.\ Copyright (c) 2006,2008,2010 Joseph Koshy. All rights reserved. .\ .\ Redistribution and use in source and binary forms, with or without .\ modification, are permitted provided that the following conditions @@ -23,7 +23,7 @@ .\ .\ $FreeBSD$ .\ -.Dd August 26, 2006 +.Dd April 30, 2010 .Dt ELF_GETDATA 3 .Os .Sh NAME @@ -193,6 +193,7 @@ An out of memory condition was detected. .Xr elf_getscn 3 , .Xr elf_getshdr 3 , .Xr elf_newscn 3 , +.Xr elf_rawfile 3 , .Xr elf_update 3 , .Xr elf_version 3 , .Xr gelf 3 Modified: stable/8/lib/libelf/libelf_data.c == --- stable/8/lib/libelf/libelf_data.c Sat Sep 4 12:52:51 2010 (r212205) +++ stable/8/lib/libelf/libelf_data.c Sat Sep 4 13:00:22 2010 (r212206) @@ -77,6 +77,8 @@ _libelf_xlate_shtype(uint32_t sht) return (ELF_T_MOVE); case SHT_SUNW_syminfo: return (ELF_T_SYMINFO); + case SHT_SUNW_dof: + return (ELF_T_BYTE); #endif case SHT_AMD64_UNWIND: /* == SHT_IA_64_UNWIND */ return (ELF_T_BYTE); ___ svn-src-all@freebsd.org mailing list
svn commit: r212207 - stable/7/lib/libelf
Author: kaiw Date: Sat Sep 4 13:00:28 2010 New Revision: 212207 URL: http://svn.freebsd.org/changeset/base/212207 Log: MFC r210351-r210353,r211192. r210351: * Note that ar(1) archives may also be opened using `elf_memory(3)`. * Ignore the passed in value of the `fd` argument for ar(1) archives opened with elf_memory(3). r210352: Add a cross-reference to `elf_rawfile(3)`. r210353: * Remove a superfluous error description. * Document an additional error that may be returned: `ELF_E_ARCHIVE`. r211192: Add translation support for section type SHT_SUNW_dof. Modified: stable/7/lib/libelf/elf_begin.3 stable/7/lib/libelf/elf_begin.c stable/7/lib/libelf/elf_getdata.3 stable/7/lib/libelf/libelf_data.c Directory Properties: stable/7/lib/libelf/ (props changed) Modified: stable/7/lib/libelf/elf_begin.3 == --- stable/7/lib/libelf/elf_begin.3 Sat Sep 4 13:00:22 2010 (r212206) +++ stable/7/lib/libelf/elf_begin.3 Sat Sep 4 13:00:28 2010 (r212207) @@ -23,7 +23,7 @@ .\ .\ $FreeBSD$ .\ -.Dd June 21, 2006 +.Dd June 20, 2010 .Os .Dt ELF_BEGIN 3 .Sh NAME @@ -163,7 +163,9 @@ archive may be opened in read mode (with set to .Dv ELF_C_READ ) using -.Fn elf_begin . +.Fn elf_begin +or +.Fn elf_memory . The returned ELF descriptor can be passed into to subsequent calls to .Fn elf_begin @@ -222,6 +224,10 @@ Function can fail with the following errors: .Pp .Bl -tag -width [ELF_E_RESOURCE] +.It Bq Er ELF_E_ARCHIVE +The archive denoted by argument +.Ar elf +could not be parsed. .It Bq Er ELF_E_ARGUMENT An unrecognized value was specified in argument .Ar cmd . @@ -245,12 +251,6 @@ differs from the value specified when EL .Ar elf was created. .It Bq Er ELF_E_ARGUMENT -Argument -.Ar elf -was not a descriptor for an -.Xr ar 1 -archive. -.It Bq Er ELF_E_ARGUMENT An .Xr ar 1 archive was opened with with Modified: stable/7/lib/libelf/elf_begin.c == --- stable/7/lib/libelf/elf_begin.c Sat Sep 4 13:00:22 2010 (r212206) +++ stable/7/lib/libelf/elf_begin.c Sat Sep 4 13:00:28 2010 (r212207) @@ -131,13 +131,15 @@ elf_begin(int fd, Elf_Cmd c, Elf *a) case ELF_C_READ: /* * Descriptor `a' could be for a regular ELF file, or -* for an ar(1) archive. +* for an ar(1) archive. If descriptor `a' was opened +* using a valid file descriptor, we need to check if +* the passed in `fd' value matches the original one. */ - if (a (a-e_fd != fd || c != a-e_cmd)) { + if (a + ((a-e_fd != -1 a-e_fd != fd) || c != a-e_cmd)) { LIBELF_SET_ERROR(ARGUMENT, 0); return (NULL); } - break; default: @@ -149,7 +151,7 @@ elf_begin(int fd, Elf_Cmd c, Elf *a) if (a == NULL) e = _libelf_open_object(fd, c); else if (a-e_kind == ELF_K_AR) - e = _libelf_ar_open_member(fd, c, a); + e = _libelf_ar_open_member(a-e_fd, c, a); else (e = a)-e_activations++; Modified: stable/7/lib/libelf/elf_getdata.3 == --- stable/7/lib/libelf/elf_getdata.3 Sat Sep 4 13:00:22 2010 (r212206) +++ stable/7/lib/libelf/elf_getdata.3 Sat Sep 4 13:00:28 2010 (r212207) @@ -1,4 +1,4 @@ -.\ Copyright (c) 2006,2008 Joseph Koshy. All rights reserved. +.\ Copyright (c) 2006,2008,2010 Joseph Koshy. All rights reserved. .\ .\ Redistribution and use in source and binary forms, with or without .\ modification, are permitted provided that the following conditions @@ -23,7 +23,7 @@ .\ .\ $FreeBSD$ .\ -.Dd August 26, 2006 +.Dd April 30, 2010 .Os .Dt ELF_GETDATA 3 .Sh NAME @@ -193,6 +193,7 @@ An out of memory condition was detected. .Xr elf_getscn 3 , .Xr elf_getshdr 3 , .Xr elf_newscn 3 , +.Xr elf_rawfile 3 , .Xr elf_update 3 , .Xr elf_version 3 , .Xr gelf 3 Modified: stable/7/lib/libelf/libelf_data.c == --- stable/7/lib/libelf/libelf_data.c Sat Sep 4 13:00:22 2010 (r212206) +++ stable/7/lib/libelf/libelf_data.c Sat Sep 4 13:00:28 2010 (r212207) @@ -77,6 +77,8 @@ _libelf_xlate_shtype(uint32_t sht) return (ELF_T_MOVE); case SHT_SUNW_syminfo: return (ELF_T_SYMINFO); + case SHT_SUNW_dof: + return (ELF_T_BYTE); #endif case SHT_AMD64_UNWIND: /* == SHT_IA_64_UNWIND */ return (ELF_T_BYTE); ___ svn-src-all@freebsd.org mailing list
svn commit: r212208 - stable/8/lib/libelf
Author: kaiw Date: Sat Sep 4 13:13:00 2010 New Revision: 212208 URL: http://svn.freebsd.org/changeset/base/212208 Log: MFC r210331-r210333,r210335,r210336,r210338,r210340,r210341,r210559. r210331: Add a new ELF type denoting GNU style hash tables. r210332: Changes for supporting GNU Hash sections. r210333: Note that the *_fsize() functions are only defined for ELF types that have a fixed size. r210335: - Return zero for file sizes of ELF types that have a variable size. - Neaten a few comments. r210336: Reduce verbosity. r210338: Perform additional checks when translating between file and memory representations of ELF types. The ELF(3) API allows applications to request a conversion that is `in-place', i.e., with source and destinations data buffers being the same. However, the file and memory sizes of ELF sections that have additional internal structure, such as those of type `Elf_Note', or `Elf_GNU_Hash_Header', can be determined only known after the type-specific headers that comprise the first few words in these sections are read and translated. Pass in the size of destination buffer to type translation routines in libelf_convert.m4 and have these routines return an error code if the translated data would not fit inside the destination buffer. r210340: - Document that the *fsize() functions return a size of 1 for Elf types that don't have a fixed size. - The *fsize() functions should return a size of 1, for variable length types. - Redefine symbol ELF_T_LAST to match the current end of the list. r210341: Add support for translating sections of type ELF_T_GNUHASH. r210559: Protect GNUHASH translation functions with #ifdef; unbreak cross toolchain build. Modified: stable/8/lib/libelf/_libelf.h stable/8/lib/libelf/elf_data.c stable/8/lib/libelf/elf_scn.c stable/8/lib/libelf/elf_types.m4 stable/8/lib/libelf/gelf_fsize.3 stable/8/lib/libelf/libelf.h stable/8/lib/libelf/libelf_align.c stable/8/lib/libelf/libelf_convert.m4 stable/8/lib/libelf/libelf_data.c stable/8/lib/libelf/libelf_ehdr.c stable/8/lib/libelf/libelf_fsize.m4 stable/8/lib/libelf/libelf_msize.m4 stable/8/lib/libelf/libelf_phdr.c stable/8/lib/libelf/libelf_xlate.c Directory Properties: stable/8/lib/libelf/ (props changed) Modified: stable/8/lib/libelf/_libelf.h == --- stable/8/lib/libelf/_libelf.h Sat Sep 4 13:00:28 2010 (r212207) +++ stable/8/lib/libelf/_libelf.h Sat Sep 4 13:13:00 2010 (r212208) @@ -175,8 +175,8 @@ void*_libelf_ehdr(Elf *_e, int _elfclas int_libelf_falign(Elf_Type _t, int _elfclass); size_t _libelf_fsize(Elf_Type _t, int _elfclass, unsigned int _version, size_t count); -void (*_libelf_get_translator(Elf_Type _t, int _direction, int _elfclass)) - (char *_dst, char *_src, size_t _cnt, int _byteswap); +int(*_libelf_get_translator(Elf_Type _t, int _direction, int _elfclass)) + (char *_dst, size_t dsz, char *_src, size_t _cnt, int _byteswap); void *_libelf_getphdr(Elf *_e, int _elfclass); void *_libelf_getshdr(Elf_Scn *_scn, int _elfclass); void _libelf_init_elf(Elf *_e, Elf_Kind _kind); Modified: stable/8/lib/libelf/elf_data.c == --- stable/8/lib/libelf/elf_data.c Sat Sep 4 13:00:28 2010 (r212207) +++ stable/8/lib/libelf/elf_data.c Sat Sep 4 13:13:00 2010 (r212208) @@ -43,7 +43,7 @@ elf_getdata(Elf_Scn *s, Elf_Data *d) int elfclass, elftype; unsigned int sh_type; uint64_t sh_align, sh_offset, sh_size; - void (*xlate)(char *_d, char *_s, size_t _c, int _swap); + int (*xlate)(char *_d, size_t _dsz, char *_s, size_t _c, int _swap); if (s == NULL || (e = s-s_elf) == NULL || e-e_kind != ELF_K_ELF || (d != NULL s != d-d_scn)) { @@ -125,11 +125,16 @@ elf_getdata(Elf_Scn *s, Elf_Data *d) } d-d_flags |= LIBELF_F_MALLOCED; - STAILQ_INSERT_TAIL(s-s_data, d, d_next); xlate = _libelf_get_translator(elftype, ELF_TOMEMORY, elfclass); - (*xlate)(d-d_buf, e-e_rawfile + sh_offset, count, e-e_byteorder != - LIBELF_PRIVATE(byteorder)); + if (!(*xlate)(d-d_buf, d-d_size, e-e_rawfile + sh_offset, count, + e-e_byteorder != LIBELF_PRIVATE(byteorder))) { + _libelf_release_data(d); + LIBELF_SET_ERROR(DATA, 0); + return (NULL); + } + + STAILQ_INSERT_TAIL(s-s_data, d, d_next); return (d); } Modified: stable/8/lib/libelf/elf_scn.c == --- stable/8/lib/libelf/elf_scn.c Sat Sep 4 13:00:28 2010 (r212207) +++
svn commit: r211192 - head/lib/libelf
Author: kaiw Date: Wed Aug 11 19:59:31 2010 New Revision: 211192 URL: http://svn.freebsd.org/changeset/base/211192 Log: Add translation support for section type SHT_SUNW_dof. Submitted by: rpaulo MFC after:2 weeks Modified: head/lib/libelf/libelf_data.c Modified: head/lib/libelf/libelf_data.c == --- head/lib/libelf/libelf_data.c Wed Aug 11 19:56:09 2010 (r211191) +++ head/lib/libelf/libelf_data.c Wed Aug 11 19:59:31 2010 (r211192) @@ -81,6 +81,8 @@ _libelf_xlate_shtype(uint32_t sht) return (ELF_T_MOVE); case SHT_SUNW_syminfo: return (ELF_T_SYMINFO); + case SHT_SUNW_dof: + return (ELF_T_BYTE); #endif case SHT_AMD64_UNWIND: /* == SHT_IA_64_UNWIND */ return (ELF_T_BYTE); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r210559 - head/lib/libelf
Author: kaiw Date: Wed Jul 28 11:01:07 2010 New Revision: 210559 URL: http://svn.freebsd.org/changeset/base/210559 Log: Protect GNUHASH translation functions with #ifdef; unbreak cross toolchain build. Reported by: jchandra MFC after:1 month Modified: head/lib/libelf/libelf_convert.m4 Modified: head/lib/libelf/libelf_convert.m4 == --- head/lib/libelf/libelf_convert.m4 Wed Jul 28 09:17:42 2010 (r210558) +++ head/lib/libelf/libelf_convert.m4 Wed Jul 28 11:01:07 2010 (r210559) @@ -507,6 +507,7 @@ libelf_cvt_BYTE_tox(char *dst, size_t ds MAKE_TYPE_CONVERTERS(ELF_TYPE_LIST) +#if__FreeBSD_version = 800062 /* * Sections of type ELF_T_GNUHASH start with a header containing 4 32-bit * words. Bloom filter data comes next, followed by hash buckets and the @@ -700,6 +701,7 @@ libelf_cvt64_GNUHASH_tof(char *dst, size return (1); } +#endif /* * Elf_Note structures comprise a fixed size header followed by variable @@ -873,12 +875,14 @@ CONVERTER_NAMES(ELF_TYPE_LIST) .tom64 = libelf_cvt_BYTE_tox }, +#if__FreeBSD_version = 800062 [ELF_T_GNUHASH] = { .tof32 = libelf_cvt32_GNUHASH_tof, .tom32 = libelf_cvt32_GNUHASH_tom, .tof64 = libelf_cvt64_GNUHASH_tof, .tom64 = libelf_cvt64_GNUHASH_tom }, +#endif [ELF_T_NOTE] = { .tof32 = libelf_cvt_NOTE_tof, ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r210321 - head/lib/libelf
Author: kaiw Date: Wed Jul 21 08:43:48 2010 New Revision: 210321 URL: http://svn.freebsd.org/changeset/base/210321 Log: Remove a superfluous comment. Obtained from: elftoolchain MFC after: 1 month Modified: head/lib/libelf/elf_update.c Modified: head/lib/libelf/elf_update.c == --- head/lib/libelf/elf_update.cWed Jul 21 08:27:56 2010 (r210320) +++ head/lib/libelf/elf_update.cWed Jul 21 08:43:48 2010 (r210321) @@ -297,7 +297,6 @@ _libelf_resync_sections(Elf *e, off_t rc else sh_type = s-s_shdr.s_shdr64.sh_type; - /* XXX Do we need the 'size' field of an SHT_NOBITS section */ if (sh_type == SHT_NOBITS || sh_type == SHT_NULL) continue; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r210324 - head/lib/libelf
Author: kaiw Date: Wed Jul 21 08:54:46 2010 New Revision: 210324 URL: http://svn.freebsd.org/changeset/base/210324 Log: - 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 Modified: head/lib/libelf/elf_data.c head/lib/libelf/elf_getdata.3 Modified: head/lib/libelf/elf_data.c == --- head/lib/libelf/elf_data.c Wed Jul 21 08:51:38 2010(r210323) +++ head/lib/libelf/elf_data.c Wed Jul 21 08:54:46 2010(r210324) @@ -39,7 +39,6 @@ Elf_Data * elf_getdata(Elf_Scn *s, Elf_Data *d) { Elf *e; - char *dst; size_t fsz, msz, count; int elfclass, elftype; unsigned int sh_type; @@ -79,20 +78,22 @@ elf_getdata(Elf_Scn *s, Elf_Data *d) sh_align = s-s_shdr.s_shdr64.sh_addralign; } + if (sh_type == SHT_NULL) + return (NULL); + if ((elftype = _libelf_xlate_shtype(sh_type)) ELF_T_FIRST || - elftype ELF_T_LAST || - sh_offset + sh_size (uint64_t) e-e_rawsize) { + elftype ELF_T_LAST || (sh_type != SHT_NOBITS + sh_offset + sh_size (uint64_t) e-e_rawsize)) { LIBELF_SET_ERROR(SECTION, 0); return (NULL); } - if ((fsz = (elfclass == ELFCLASS32 ? elf32_fsize : elf64_fsize)(elftype, -(size_t) 1, e-e_version)) == 0) { + if ((fsz = (elfclass == ELFCLASS32 ? elf32_fsize : elf64_fsize) +(elftype, (size_t) 1, e-e_version)) == 0) { LIBELF_SET_ERROR(UNIMPL, 0); return (NULL); } - if (sh_size % fsz) { LIBELF_SET_ERROR(SECTION, 0); return (NULL); @@ -104,21 +105,25 @@ elf_getdata(Elf_Scn *s, Elf_Data *d) assert(msz 0); - if ((dst = malloc(msz*count)) == NULL) { - LIBELF_SET_ERROR(RESOURCE, 0); - return (NULL); - } - if ((d = _libelf_allocate_data(s)) == NULL) return (NULL); - d-d_buf = dst; + d-d_buf = NULL; d-d_off = 0; d-d_align = sh_align; d-d_size= msz * count; d-d_type= elftype; d-d_version = e-e_version; + if (sh_type == SHT_NOBITS) + return (d); + + if ((d-d_buf = malloc(msz*count)) == NULL) { + (void) _libelf_release_data(d); + LIBELF_SET_ERROR(RESOURCE, 0); + return (NULL); + } + d-d_flags |= LIBELF_F_MALLOCED; STAILQ_INSERT_TAIL(s-s_data, d, d_next); @@ -149,14 +154,10 @@ elf_newdata(Elf_Scn *s) if (elf_getdata(s, NULL) == NULL) return (NULL); - if ((d = malloc(sizeof(Elf_Data))) == NULL) { - LIBELF_SET_ERROR(RESOURCE, errno); + if ((d = _libelf_allocate_data(s)) == NULL) return (NULL); - } STAILQ_INSERT_TAIL(s-s_data, d, d_next); - d-d_flags = 0; - d-d_scn = s; d-d_align = 1; d-d_buf = NULL; @@ -180,6 +181,7 @@ elf_rawdata(Elf_Scn *s, Elf_Data *d) { Elf *e; int elf_class; + uint32_t sh_type; uint64_t sh_align, sh_offset, sh_size; if (s == NULL || (e = s-s_elf) == NULL || @@ -199,19 +201,24 @@ elf_rawdata(Elf_Scn *s, Elf_Data *d) assert(elf_class == ELFCLASS32 || elf_class == ELFCLASS64); if (elf_class == ELFCLASS32) { + sh_type = s-s_shdr.s_shdr32.sh_type; sh_offset = (uint64_t) s-s_shdr.s_shdr32.sh_offset; sh_size = (uint64_t) s-s_shdr.s_shdr32.sh_size; sh_align = (uint64_t) s-s_shdr.s_shdr32.sh_addralign; } else { + sh_type = s-s_shdr.s_shdr64.sh_type; sh_offset = s-s_shdr.s_shdr64.sh_offset; sh_size = s-s_shdr.s_shdr64.sh_size; sh_align = s-s_shdr.s_shdr64.sh_addralign; } + if (sh_type == SHT_NULL) + return (NULL); + if ((d = _libelf_allocate_data(s)) == NULL) return (NULL); - d-d_buf = e-e_rawfile + sh_offset; + d-d_buf = sh_type == SHT_NOBITS ? NULL : e-e_rawfile + sh_offset; d-d_off = 0; d-d_align = sh_align; d-d_size= sh_size; Modified: head/lib/libelf/elf_getdata.3 == --- head/lib/libelf/elf_getdata.3 Wed Jul 21
svn commit: r210325 - head/lib/libelf
Author: kaiw Date: Wed Jul 21 08:58:52 2010 New Revision: 210325 URL: http://svn.freebsd.org/changeset/base/210325 Log: Bug fix: when updating headers using the gelf_update_*() functions, the appropriate `dirty' bit needs to be set for both the Elf32 and Elf64 case. Obtained from:elftoolchain MFC after:1 month Modified: head/lib/libelf/gelf_ehdr.c head/lib/libelf/gelf_phdr.c head/lib/libelf/gelf_shdr.c Modified: head/lib/libelf/gelf_ehdr.c == --- head/lib/libelf/gelf_ehdr.c Wed Jul 21 08:54:46 2010(r210324) +++ head/lib/libelf/gelf_ehdr.c Wed Jul 21 08:58:52 2010(r210325) @@ -137,6 +137,8 @@ gelf_update_ehdr(Elf *e, GElf_Ehdr *s) if ((ehdr = _libelf_ehdr(e, ec, 0)) == NULL) return (0); + (void) elf_flagehdr(e, ELF_C_SET, ELF_F_DIRTY); + if (ec == ELFCLASS64) { eh64 = (Elf64_Ehdr *) ehdr; *eh64 = *s; @@ -161,7 +163,5 @@ gelf_update_ehdr(Elf *e, GElf_Ehdr *s) eh32-e_shnum = s-e_shnum; eh32-e_shstrndx = s-e_shstrndx; - (void) elf_flagehdr(e, ELF_C_SET, ELF_F_DIRTY); - return (1); } Modified: head/lib/libelf/gelf_phdr.c == --- head/lib/libelf/gelf_phdr.c Wed Jul 21 08:54:46 2010(r210324) +++ head/lib/libelf/gelf_phdr.c Wed Jul 21 08:58:52 2010(r210325) @@ -155,6 +155,8 @@ gelf_update_phdr(Elf *e, int ndx, GElf_P return (0); } + (void) elf_flagphdr(e, ELF_C_SET, ELF_F_DIRTY); + if (ec == ELFCLASS64) { ph64 = e-e_u.e_elf.e_phdr.e_phdr64 + ndx; *ph64 = *s; @@ -172,7 +174,5 @@ gelf_update_phdr(Elf *e, int ndx, GElf_P LIBELF_COPY_U32(ph32, s, p_memsz); LIBELF_COPY_U32(ph32, s, p_align); - (void) elf_flagphdr(e, ELF_C_SET, ELF_F_DIRTY); - return (1); } Modified: head/lib/libelf/gelf_shdr.c == --- head/lib/libelf/gelf_shdr.c Wed Jul 21 08:54:46 2010(r210324) +++ head/lib/libelf/gelf_shdr.c Wed Jul 21 08:58:52 2010(r210325) @@ -107,6 +107,8 @@ gelf_update_shdr(Elf_Scn *scn, GElf_Shdr return (0); } + (void) elf_flagscn(scn, ELF_C_SET, ELF_F_DIRTY); + if (ec == ELFCLASS64) { scn-s_shdr.s_shdr64 = *s; return (1); @@ -125,7 +127,5 @@ gelf_update_shdr(Elf_Scn *scn, GElf_Shdr LIBELF_COPY_U32(sh32, s, sh_addralign); LIBELF_COPY_U32(sh32, s, sh_entsize); - (void) elf_flagscn(scn, ELF_C_SET, ELF_F_DIRTY); - return (1); } ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
Re: svn commit: r210324 - head/lib/libelf
On Wed, Jul 21, 2010 at 10:51:17AM +0200, Roman Divacky wrote: On Wed, Jul 21, 2010 at 08:54:46AM +, Kai Wang wrote: Author: kaiw Date: Wed Jul 21 08:54:46 2010 New Revision: 210324 URL: http://svn.freebsd.org/changeset/base/210324 Log: - 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. this is the fix that fixes -flto with gcc45? No. This fixes is irrelevant to gcc LTO. Actually, this partially fixed the empty section problem reported by k...@. I'll write you and kan@ a private mail about kan@'s patch later. Kai ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
Re: svn commit: r210321 - head/lib/libelf
On Wed, Jul 21, 2010 at 09:06:23AM +, Alexey Dokuchaev wrote: On Wed, Jul 21, 2010 at 08:43:48AM +, Kai Wang wrote: Author: kaiw Date: Wed Jul 21 08:43:48 2010 New Revision: 210321 URL: http://svn.freebsd.org/changeset/base/210321 Log: Remove a superfluous comment. Obtained from: elftoolchain MFC after: 1 month (Just picking random of the similar commits): guys, please, try to uniformly align commit meta tags: Obtained from:somewhere MFC after:sometime Foo bar: baz qux ... Broken alignment considerably pessimizes commit log grasping, as it requires more post-processing work after reading it off. My bad for this one... I actually aligned it in editor at first. However, since I was using hard tabs and commit log prepends two spaces for each line, the resulted commit log became unaligned... Kai ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r210326 - head/lib/libelf
Author: kaiw Date: Wed Jul 21 09:20:40 2010 New Revision: 210326 URL: http://svn.freebsd.org/changeset/base/210326 Log: Improve compatibility with other implementations of the ELF(3) API: when an output file has no program headers, set the 'e_phentsize' field of the ELF executable header to zero. Obtained from:elftoolchain MFC after:1 month Modified: head/lib/libelf/elf_update.c Modified: head/lib/libelf/elf_update.c == --- head/lib/libelf/elf_update.cWed Jul 21 08:58:52 2010 (r210325) +++ head/lib/libelf/elf_update.cWed Jul 21 09:20:40 2010 (r210326) @@ -422,8 +422,8 @@ _libelf_resync_elf(Elf *e) (E)-e_ident[EI_VERSION] = (V); \ (E)-e_ehsize = _libelf_fsize(ELF_T_EHDR, (EC), (V),\ (size_t) 1);\ - (E)-e_phentsize = _libelf_fsize(ELF_T_PHDR, (EC), (V), \ - (size_t) 1);\ + (E)-e_phentsize = (phnum == 0) ? 0 : _libelf_fsize(\ + ELF_T_PHDR, (EC), (V), (size_t) 1); \ (E)-e_shentsize = _libelf_fsize(ELF_T_SHDR, (EC), (V), \ (size_t) 1);\ } while (0) ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r210328 - head/lib/libelf
Author: kaiw Date: Wed Jul 21 09:27:16 2010 New Revision: 210328 URL: http://svn.freebsd.org/changeset/base/210328 Log: Bug fix: permit the creation of zero-sized sections. Obtained from:elftoolchain MFC after:1 month Modified: head/lib/libelf/elf_update.c Modified: head/lib/libelf/elf_update.c == --- head/lib/libelf/elf_update.cWed Jul 21 09:27:00 2010 (r210327) +++ head/lib/libelf/elf_update.cWed Jul 21 09:27:16 2010 (r210328) @@ -534,22 +534,24 @@ _libelf_write_scn(Elf *e, char *nf, Elf_ int ec; size_t fsz, msz, nobjects; uint32_t sh_type; - uint64_t sh_off; + uint64_t sh_off, sh_size; int elftype; Elf_Data *d, dst; - if ((ec = e-e_class) == ELFCLASS32) + if ((ec = e-e_class) == ELFCLASS32) { sh_type = s-s_shdr.s_shdr32.sh_type; - else + sh_size = (uint64_t) s-s_shdr.s_shdr32.sh_size; + } else { sh_type = s-s_shdr.s_shdr64.sh_type; + sh_size = s-s_shdr.s_shdr64.sh_size; + } /* * Ignore sections that do not allocate space in the file. */ - if (sh_type == SHT_NOBITS || sh_type == SHT_NULL) + if (sh_type == SHT_NOBITS || sh_type == SHT_NULL || sh_size == 0) return (rc); - elftype = _libelf_xlate_shtype(sh_type); assert(elftype = ELF_T_FIRST elftype = ELF_T_LAST); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r210329 - head/lib/libelf
Author: kaiw Date: Wed Jul 21 09:33:45 2010 New Revision: 210329 URL: http://svn.freebsd.org/changeset/base/210329 Log: Use unistd.h to declare the prototype for ftruncate(). Obtained from:elftoolchain MFC after:1 month Modified: head/lib/libelf/elf_begin.c Modified: head/lib/libelf/elf_begin.c == --- head/lib/libelf/elf_begin.c Wed Jul 21 09:27:16 2010(r210328) +++ head/lib/libelf/elf_begin.c Wed Jul 21 09:33:45 2010(r210329) @@ -35,6 +35,7 @@ __FBSDID($FreeBSD$); #include ar.h #include ctype.h #include libelf.h +#include unistd.h #include _libelf.h ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r210330 - head/lib/libelf
Author: kaiw Date: Wed Jul 21 09:47:14 2010 New Revision: 210330 URL: http://svn.freebsd.org/changeset/base/210330 Log: Allow an application that updates only the ELF Ehdr to work. Obtained from:elftoolchain MFC after:1 month Modified: head/lib/libelf/_libelf.h head/lib/libelf/elf_scn.c head/lib/libelf/elf_update.c Modified: head/lib/libelf/_libelf.h == --- head/lib/libelf/_libelf.h Wed Jul 21 09:33:45 2010(r210329) +++ head/lib/libelf/_libelf.h Wed Jul 21 09:47:14 2010(r210330) @@ -176,6 +176,7 @@ void(*_libelf_get_translator(Elf_Type _ void *_libelf_getphdr(Elf *_e, int _elfclass); void *_libelf_getshdr(Elf_Scn *_scn, int _elfclass); void _libelf_init_elf(Elf *_e, Elf_Kind _kind); +int_libelf_load_scn(Elf *e, void *ehdr); int_libelf_malign(Elf_Type _t, int _elfclass); size_t _libelf_msize(Elf_Type _t, int _elfclass, unsigned int _version); void *_libelf_newphdr(Elf *_e, int _elfclass, size_t _count); Modified: head/lib/libelf/elf_scn.c == --- head/lib/libelf/elf_scn.c Wed Jul 21 09:33:45 2010(r210329) +++ head/lib/libelf/elf_scn.c Wed Jul 21 09:47:14 2010(r210330) @@ -38,7 +38,7 @@ __FBSDID($FreeBSD$); /* * Load an ELF section table and create a list of Elf_Scn structures. */ -static int +int _libelf_load_scn(Elf *e, void *ehdr) { int ec, swapbytes; Modified: head/lib/libelf/elf_update.c == --- head/lib/libelf/elf_update.cWed Jul 21 09:33:45 2010 (r210329) +++ head/lib/libelf/elf_update.cWed Jul 21 09:47:14 2010 (r210330) @@ -472,6 +472,11 @@ _libelf_resync_elf(Elf *e) * file. */ + if (e-e_cmd != ELF_C_WRITE + (e-e_flags LIBELF_F_SHDRS_LOADED) == 0 + _libelf_load_scn(e, ehdr) == 0) + return ((off_t) -1); + if ((rc = _libelf_resync_sections(e, rc)) 0) return ((off_t) -1); @@ -726,14 +731,9 @@ _libelf_write_elf(Elf *e, off_t newsize) assert(phoff % _libelf_falign(ELF_T_PHDR, ec) == 0); assert(fsz 0); + src.d_buf = _libelf_getphdr(e, ec); src.d_version = dst.d_version = e-e_version; src.d_type = ELF_T_PHDR; - - if (ec == ELFCLASS32) - src.d_buf = e-e_u.e_elf.e_phdr.e_phdr32; - else - src.d_buf = e-e_u.e_elf.e_phdr.e_phdr64; - src.d_size = phnum * _libelf_msize(ELF_T_PHDR, ec, e-e_version); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r210331 - head/lib/libelf
Author: kaiw Date: Wed Jul 21 09:51:24 2010 New Revision: 210331 URL: http://svn.freebsd.org/changeset/base/210331 Log: Add a new ELF type denoting GNU style hash tables. Obtained from:elftoolchain MFC after:1 month Modified: head/lib/libelf/libelf.h Modified: head/lib/libelf/libelf.h == --- head/lib/libelf/libelf.hWed Jul 21 09:47:14 2010(r210330) +++ head/lib/libelf/libelf.hWed Jul 21 09:51:24 2010(r210331) @@ -75,6 +75,7 @@ typedef enum { ELF_T_VNEED, ELF_T_WORD, ELF_T_XWORD, + ELF_T_GNUHASH, /* GNU style hash tables. */ ELF_T_NUM } Elf_Type; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r210332 - head/lib/libelf
Author: kaiw Date: Wed Jul 21 09:56:42 2010 New Revision: 210332 URL: http://svn.freebsd.org/changeset/base/210332 Log: Changes for supporting GNU Hash sections. Obtained from:elftoolchain MFC after:1 month Modified: head/lib/libelf/libelf_align.c head/lib/libelf/libelf_fsize.m4 head/lib/libelf/libelf_msize.m4 Modified: head/lib/libelf/libelf_align.c == --- head/lib/libelf/libelf_align.c Wed Jul 21 09:51:24 2010 (r210331) +++ head/lib/libelf/libelf_align.c Wed Jul 21 09:56:42 2010 (r210332) @@ -51,6 +51,10 @@ struct align { .a32 = 0, \ .a64 = __alignof__(Elf64_##V) \ } +#defineMALIGN_WORD() { \ + .a32 = __alignof__(int32_t),\ + .a64 = __alignof__(int64_t) \ + } #else #error Need the __alignof__ builtin. #endif @@ -92,7 +96,10 @@ static struct align malign[ELF_T_NUM] = [ELF_T_VNEED] = MALIGN(Verneed), #endif [ELF_T_WORD]= MALIGN(Word), - [ELF_T_XWORD] = MALIGN64(Xword) + [ELF_T_XWORD] = MALIGN64(Xword), +#if__FreeBSD_version = 800062 + [ELF_T_GNUHASH] = MALIGN_WORD() +#endif }; int @@ -140,7 +147,10 @@ static struct align falign[ELF_T_NUM] = [ELF_T_VNEED] = FALIGN(4,4), #endif [ELF_T_WORD]= FALIGN(4,4), - [ELF_T_XWORD] = FALIGN(0,8) + [ELF_T_XWORD] = FALIGN(0,8), +#if__FreeBSD_version = 800062 + [ELF_T_GNUHASH] = FALIGN(4,8) +#endif }; int Modified: head/lib/libelf/libelf_fsize.m4 == --- head/lib/libelf/libelf_fsize.m4 Wed Jul 21 09:51:24 2010 (r210331) +++ head/lib/libelf/libelf_fsize.m4 Wed Jul 21 09:56:42 2010 (r210332) @@ -45,6 +45,7 @@ include(SRCDIR`/elf_types.m4') /* `Basic' types */ define(`BYTE_SIZE',1) +define(`GNUHASH_SIZE', 1) /* Elf_GNU_Hash_Header structures vary in length. */ define(`IDENT_SIZE', `EI_NIDENT') define(`NOTE_SIZE',1) /* Elf_Note structures have variable length. */ Modified: head/lib/libelf/libelf_msize.m4 == --- head/lib/libelf/libelf_msize.m4 Wed Jul 21 09:51:24 2010 (r210331) +++ head/lib/libelf/libelf_msize.m4 Wed Jul 21 09:56:42 2010 (r210332) @@ -49,6 +49,7 @@ divert(-1) include(SRCDIR`/elf_types.m4') define(BYTE_SIZE, 1) +define(GNUHASH_SIZE, 1) define(NOTE_SIZE, 1) /* ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r210333 - head/lib/libelf
Author: kaiw Date: Wed Jul 21 10:02:59 2010 New Revision: 210333 URL: http://svn.freebsd.org/changeset/base/210333 Log: Note that the *_fsize() functions are only defined for ELF types that have a fixed size. Obtained from:elftoolchain MFC after:1 month Modified: head/lib/libelf/gelf_fsize.3 Modified: head/lib/libelf/gelf_fsize.3 == --- head/lib/libelf/gelf_fsize.3Wed Jul 21 09:56:42 2010 (r210332) +++ head/lib/libelf/gelf_fsize.3Wed Jul 21 10:02:59 2010 (r210333) @@ -47,6 +47,9 @@ These functions return the size in bytes .Ar count numbers of objects of ELF type .Ar type . +Argument +.Ar type +must be one that has a fixed size file representation. .Pp Functions .Fn elf32_fsize @@ -80,6 +83,10 @@ had an unknown ELF class. Argument .Ar type contained an illegal value. +.It Bq Er ELF_E_ARGUMENT +Argument +.Ar type +denoted an ELF type with variable size. .It Bq Er ELF_E_UNIMPL Support for ELF type .Ar type ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r210335 - head/lib/libelf
Author: kaiw Date: Wed Jul 21 10:08:25 2010 New Revision: 210335 URL: http://svn.freebsd.org/changeset/base/210335 Log: - Return zero for file sizes of ELF types that have a variable size. - Neaten a few comments. Obtained from:elftoolchain MFC after:1 month Modified: head/lib/libelf/libelf_fsize.m4 Modified: head/lib/libelf/libelf_fsize.m4 == --- head/lib/libelf/libelf_fsize.m4 Wed Jul 21 10:05:07 2010 (r210334) +++ head/lib/libelf/libelf_fsize.m4 Wed Jul 21 10:08:25 2010 (r210335) @@ -43,16 +43,18 @@ include(SRCDIR`/elf_types.m4') * representations. */ -/* `Basic' types */ +/* `Basic' types. */ define(`BYTE_SIZE',1) -define(`GNUHASH_SIZE', 1) /* Elf_GNU_Hash_Header structures vary in length. */ define(`IDENT_SIZE', `EI_NIDENT') -define(`NOTE_SIZE',1) /* Elf_Note structures have variable length. */ -/* Currently unimplemented types */ +/* Types that have variable length. */ +define(`GNUHASH_SIZE', 0) /* Elf_GNU_Hash_Header structures vary in length. */ +define(`NOTE_SIZE',0) /* Elf_Note structures have variable length. */ + +/* Currently unimplemented types. */ define(`MOVEP_SIZE', 0) -/* Overrides for 32 bit types that do not exist */ +/* Overrides for 32 bit types that do not exist. */ define(`XWORD_SIZE32', 0) define(`SXWORD_SIZE32',0) @@ -143,7 +145,8 @@ _libelf_fsize(Elf_Type t, int ec, unsign sz = 0; if (v != EV_CURRENT) LIBELF_SET_ERROR(VERSION, 0); - else if ((int) t ELF_T_FIRST || t ELF_T_LAST) + else if ((int) t ELF_T_FIRST || t ELF_T_LAST || + t == ELF_T_NOTE || t == ELF_T_GNUHASH) LIBELF_SET_ERROR(ARGUMENT, 0); else { sz = ec == ELFCLASS64 ? fsize[t].fsz64 : fsize[t].fsz32; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r210336 - head/lib/libelf
Author: kaiw Date: Wed Jul 21 10:11:46 2010 New Revision: 210336 URL: http://svn.freebsd.org/changeset/base/210336 Log: Reduce verbosity. Obtained from:elftoolchain MFC after:1 month Modified: head/lib/libelf/libelf_fsize.m4 Modified: head/lib/libelf/libelf_fsize.m4 == --- head/lib/libelf/libelf_fsize.m4 Wed Jul 21 10:08:25 2010 (r210335) +++ head/lib/libelf/libelf_fsize.m4 Wed Jul 21 10:11:46 2010 (r210336) @@ -48,8 +48,8 @@ define(`BYTE_SIZE', 1) define(`IDENT_SIZE', `EI_NIDENT') /* Types that have variable length. */ -define(`GNUHASH_SIZE', 0) /* Elf_GNU_Hash_Header structures vary in length. */ -define(`NOTE_SIZE',0) /* Elf_Note structures have variable length. */ +define(`GNUHASH_SIZE', 0) +define(`NOTE_SIZE',0) /* Currently unimplemented types. */ define(`MOVEP_SIZE', 0) ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r210338 - head/lib/libelf
Author: kaiw Date: Wed Jul 21 10:25:02 2010 New Revision: 210338 URL: http://svn.freebsd.org/changeset/base/210338 Log: Perform additional checks when translating between file and memory representations of ELF types. The ELF(3) API allows applications to request a conversion that is `in-place', i.e., with source and destinations data buffers being the same. However, the file and memory sizes of ELF sections that have additional internal structure, such as those of type `Elf_Note', or `Elf_GNU_Hash_Header', can be determined only known after the type-specific headers that comprise the first few words in these sections are read and translated. Pass in the size of destination buffer to type translation routines in libelf_convert.m4 and have these routines return an error code if the translated data would not fit inside the destination buffer. Obtained from:elftoolchain MFC after:1 month Modified: head/lib/libelf/_libelf.h head/lib/libelf/elf_data.c head/lib/libelf/elf_scn.c head/lib/libelf/libelf_convert.m4 head/lib/libelf/libelf_ehdr.c head/lib/libelf/libelf_phdr.c head/lib/libelf/libelf_xlate.c Modified: head/lib/libelf/_libelf.h == --- head/lib/libelf/_libelf.h Wed Jul 21 10:14:04 2010(r210337) +++ head/lib/libelf/_libelf.h Wed Jul 21 10:25:02 2010(r210338) @@ -171,8 +171,8 @@ void*_libelf_ehdr(Elf *_e, int _elfclas int_libelf_falign(Elf_Type _t, int _elfclass); size_t _libelf_fsize(Elf_Type _t, int _elfclass, unsigned int _version, size_t count); -void (*_libelf_get_translator(Elf_Type _t, int _direction, int _elfclass)) - (char *_dst, char *_src, size_t _cnt, int _byteswap); +int(*_libelf_get_translator(Elf_Type _t, int _direction, int _elfclass)) + (char *_dst, size_t dsz, char *_src, size_t _cnt, int _byteswap); void *_libelf_getphdr(Elf *_e, int _elfclass); void *_libelf_getshdr(Elf_Scn *_scn, int _elfclass); void _libelf_init_elf(Elf *_e, Elf_Kind _kind); Modified: head/lib/libelf/elf_data.c == --- head/lib/libelf/elf_data.c Wed Jul 21 10:14:04 2010(r210337) +++ head/lib/libelf/elf_data.c Wed Jul 21 10:25:02 2010(r210338) @@ -43,7 +43,7 @@ elf_getdata(Elf_Scn *s, Elf_Data *d) int elfclass, elftype; unsigned int sh_type; uint64_t sh_align, sh_offset, sh_size; - void (*xlate)(char *_d, char *_s, size_t _c, int _swap); + int (*xlate)(char *_d, size_t _dsz, char *_s, size_t _c, int _swap); if (s == NULL || (e = s-s_elf) == NULL || e-e_kind != ELF_K_ELF || (d != NULL s != d-d_scn)) { @@ -125,11 +125,16 @@ elf_getdata(Elf_Scn *s, Elf_Data *d) } d-d_flags |= LIBELF_F_MALLOCED; - STAILQ_INSERT_TAIL(s-s_data, d, d_next); xlate = _libelf_get_translator(elftype, ELF_TOMEMORY, elfclass); - (*xlate)(d-d_buf, e-e_rawfile + sh_offset, count, e-e_byteorder != - LIBELF_PRIVATE(byteorder)); + if (!(*xlate)(d-d_buf, d-d_size, e-e_rawfile + sh_offset, count, + e-e_byteorder != LIBELF_PRIVATE(byteorder))) { + _libelf_release_data(d); + LIBELF_SET_ERROR(DATA, 0); + return (NULL); + } + + STAILQ_INSERT_TAIL(s-s_data, d, d_next); return (d); } Modified: head/lib/libelf/elf_scn.c == --- head/lib/libelf/elf_scn.c Wed Jul 21 10:14:04 2010(r210337) +++ head/lib/libelf/elf_scn.c Wed Jul 21 10:25:02 2010(r210338) @@ -48,7 +48,7 @@ _libelf_load_scn(Elf *e, void *ehdr) Elf32_Ehdr *eh32; Elf64_Ehdr *eh64; Elf_Scn *scn; - void (*xlator)(char *_d, char *_s, size_t _c, int _swap); + int (*xlator)(char *_d, size_t _dsz, char *_s, size_t _c, int _swap); assert(e != NULL); assert(ehdr != NULL); @@ -101,7 +101,8 @@ _libelf_load_scn(Elf *e, void *ehdr) if ((scn = _libelf_allocate_scn(e, i)) == NULL) return (0); - (*xlator)((char *) scn-s_shdr, src, (size_t) 1, swapbytes); + (*xlator)((char *) scn-s_shdr, sizeof(scn-s_shdr), src, + (size_t) 1, swapbytes); if (ec == ELFCLASS32) { scn-s_offset = scn-s_rawoff = Modified: head/lib/libelf/libelf_convert.m4 == --- head/lib/libelf/libelf_convert.m4 Wed Jul 21 10:14:04 2010 (r210337) +++ head/lib/libelf/libelf_convert.m4 Wed Jul 21 10:25:02 2010 (r210338) @@ -236,6 +236,7 @@ IGNORE(MOVEP) IGNORE(NOTE) define(IGNORE_BYTE,1) /* 'lator, leave 'em bytes alone */ +define(IGNORE_GNUHASH, 1)
svn commit: r210340 - head/lib/libelf
Author: kaiw Date: Wed Jul 21 10:39:29 2010 New Revision: 210340 URL: http://svn.freebsd.org/changeset/base/210340 Log: - Document that the *fsize() functions return a size of 1 for Elf types that don't have a fixed size. - The *fsize() functions should return a size of 1, for variable length types. - Redefine symbol ELF_T_LAST to match the current end of the list. Obtained from:elftoolchain MFC after:1 month Modified: head/lib/libelf/gelf_fsize.3 head/lib/libelf/libelf.h head/lib/libelf/libelf_data.c head/lib/libelf/libelf_fsize.m4 Modified: head/lib/libelf/gelf_fsize.3 == --- head/lib/libelf/gelf_fsize.3Wed Jul 21 10:36:27 2010 (r210339) +++ head/lib/libelf/gelf_fsize.3Wed Jul 21 10:39:29 2010 (r210340) @@ -47,9 +47,8 @@ These functions return the size in bytes .Ar count numbers of objects of ELF type .Ar type . -Argument -.Ar type -must be one that has a fixed size file representation. +For ELF types that are of variable length, these functions return a +size of one byte. .Pp Functions .Fn elf32_fsize @@ -83,10 +82,6 @@ had an unknown ELF class. Argument .Ar type contained an illegal value. -.It Bq Er ELF_E_ARGUMENT -Argument -.Ar type -denoted an ELF type with variable size. .It Bq Er ELF_E_UNIMPL Support for ELF type .Ar type Modified: head/lib/libelf/libelf.h == --- head/lib/libelf/libelf.hWed Jul 21 10:36:27 2010(r210339) +++ head/lib/libelf/libelf.hWed Jul 21 10:39:29 2010(r210340) @@ -80,7 +80,7 @@ typedef enum { } Elf_Type; #defineELF_T_FIRST ELF_T_ADDR -#defineELF_T_LAST ELF_T_XWORD +#defineELF_T_LAST ELF_T_GNUHASH /* Commands */ typedef enum { Modified: head/lib/libelf/libelf_data.c == --- head/lib/libelf/libelf_data.c Wed Jul 21 10:36:27 2010 (r210339) +++ head/lib/libelf/libelf_data.c Wed Jul 21 10:39:29 2010 (r210340) @@ -42,6 +42,10 @@ _libelf_xlate_shtype(uint32_t sht) return (ELF_T_SYM); case SHT_FINI_ARRAY: return (ELF_T_ADDR); +#if__FreeBSD_version = 800062 + case SHT_GNU_HASH: + return (ELF_T_GNUHASH); +#endif case SHT_GROUP: return (ELF_T_WORD); case SHT_HASH: Modified: head/lib/libelf/libelf_fsize.m4 == --- head/lib/libelf/libelf_fsize.m4 Wed Jul 21 10:36:27 2010 (r210339) +++ head/lib/libelf/libelf_fsize.m4 Wed Jul 21 10:39:29 2010 (r210340) @@ -48,8 +48,8 @@ define(`BYTE_SIZE', 1) define(`IDENT_SIZE', `EI_NIDENT') /* Types that have variable length. */ -define(`GNUHASH_SIZE', 0) -define(`NOTE_SIZE',0) +define(`GNUHASH_SIZE', 1) +define(`NOTE_SIZE',1) /* Currently unimplemented types. */ define(`MOVEP_SIZE', 0) @@ -145,8 +145,7 @@ _libelf_fsize(Elf_Type t, int ec, unsign sz = 0; if (v != EV_CURRENT) LIBELF_SET_ERROR(VERSION, 0); - else if ((int) t ELF_T_FIRST || t ELF_T_LAST || - t == ELF_T_NOTE || t == ELF_T_GNUHASH) + else if ((int) t ELF_T_FIRST || t ELF_T_LAST) LIBELF_SET_ERROR(ARGUMENT, 0); else { sz = ec == ELFCLASS64 ? fsize[t].fsz64 : fsize[t].fsz32; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r210341 - head/lib/libelf
Author: kaiw Date: Wed Jul 21 10:57:22 2010 New Revision: 210341 URL: http://svn.freebsd.org/changeset/base/210341 Log: Add support for translating sections of type ELF_T_GNUHASH. Obtained from:elftoolchain MFC after:1 month Modified: head/lib/libelf/elf_types.m4 head/lib/libelf/libelf_convert.m4 Modified: head/lib/libelf/elf_types.m4 == --- head/lib/libelf/elf_types.m4Wed Jul 21 10:39:29 2010 (r210340) +++ head/lib/libelf/elf_types.m4Wed Jul 21 10:57:22 2010 (r210341) @@ -46,6 +46,7 @@ define(`ELF_TYPE_LIST', `CAP, Cap,700025', `DYN, Dyn,600102', `EHDR, Ehdr, 600102', + `GNUHASH, -, 800062', `HALF, Half, 600102', `LWORD, Lword, 700025', `MOVE, Move, 700025', Modified: head/lib/libelf/libelf_convert.m4 == --- head/lib/libelf/libelf_convert.m4 Wed Jul 21 10:39:29 2010 (r210340) +++ head/lib/libelf/libelf_convert.m4 Wed Jul 21 10:57:22 2010 (r210341) @@ -234,6 +234,7 @@ define(`IGNORE', IGNORE(MOVEP) IGNORE(NOTE) +IGNORE(GNUHASH) define(IGNORE_BYTE,1) /* 'lator, leave 'em bytes alone */ define(IGNORE_GNUHASH, 1) @@ -504,12 +505,209 @@ libelf_cvt_BYTE_tox(char *dst, size_t ds return (1); } +MAKE_TYPE_CONVERTERS(ELF_TYPE_LIST) + +/* + * Sections of type ELF_T_GNUHASH start with a header containing 4 32-bit + * words. Bloom filter data comes next, followed by hash buckets and the + * hash chain. + * + * Bloom filter words are 64 bit wide on ELFCLASS64 objects and are 32 bit + * wide on ELFCLASS32 objects. The other objects in this section are 32 + * bits wide. + * + * Argument `srcsz' denotes the number of bytes to be converted. In the + * 32-bit case we need to translate `srcsz' to a count of 32-bit words. + */ + +static int +libelf_cvt32_GNUHASH_tom(char *dst, size_t dsz, char *src, size_t srcsz, +int byteswap) +{ + return (libelf_cvt_WORD_tom(dst, dsz, src, srcsz / sizeof(uint32_t), + byteswap)); +} + +static int +libelf_cvt32_GNUHASH_tof(char *dst, size_t dsz, char *src, size_t srcsz, +int byteswap) +{ + return (libelf_cvt_WORD_tof(dst, dsz, src, srcsz / sizeof(uint32_t), + byteswap)); +} + +static int +libelf_cvt64_GNUHASH_tom(char *dst, size_t dsz, char *src, size_t srcsz, +int byteswap) +{ + size_t sz; + uint64_t t64, *bloom64; + Elf_GNU_Hash_Header *gh; + uint32_t n, nbuckets, nchains, maskwords, shift2, symndx, t32; + uint32_t *buckets, *chains; + + sz = 4 * sizeof(uint32_t); /* File header is 4 words long. */ + if (dsz sizeof(Elf_GNU_Hash_Header) || srcsz sz) + return (0); + + /* Read in the section header and byteswap if needed. */ + READ_WORD(src, nbuckets); + READ_WORD(src, symndx); + READ_WORD(src, maskwords); + READ_WORD(src, shift2); + + srcsz -= sz; + + if (byteswap) { + SWAP_WORD(nbuckets); + SWAP_WORD(symndx); + SWAP_WORD(maskwords); + SWAP_WORD(shift2); + } + + /* Check source buffer and destination buffer sizes. */ + sz = nbuckets * sizeof(uint32_t) + maskwords * sizeof(uint64_t); + if (srcsz sz || dsz sz + sizeof(Elf_GNU_Hash_Header)) + return (0); + + gh = (Elf_GNU_Hash_Header *) (uintptr_t) dst; + gh-gh_nbuckets = nbuckets; + gh-gh_symndx= symndx; + gh-gh_maskwords = maskwords; + gh-gh_shift2= shift2; + + dsz -= sizeof(Elf_GNU_Hash_Header); + dst += sizeof(Elf_GNU_Hash_Header); + + bloom64 = (uint64_t *) (uintptr_t) dst; + + /* Copy bloom filter data. */ + for (n = 0; n maskwords; n++) { + READ_XWORD(src, t64); + if (byteswap) + SWAP_XWORD(t64); + bloom64[n] = t64; + } + + /* The hash buckets follows the bloom filter. */ + dst += maskwords * sizeof(uint64_t); + buckets = (uint32_t *) (uintptr_t) dst; + + for (n = 0; n nbuckets; n++) { + READ_WORD(src, t32); + if (byteswap) + SWAP_WORD(t32); + buckets[n] = t32; + } + + dst += nbuckets * sizeof(uint32_t); + + /* The hash chain follows the hash buckets. */ + dsz -= sz; + srcsz -= sz; + + if (dsz srcsz)/* Destination lacks space. */ + return (0); + + nchains = srcsz / sizeof(uint32_t); + chains = (uint32_t *) (uintptr_t) dst; + + for (n = 0; n nchains; n++) { + READ_WORD(src, t32); + if (byteswap) + SWAP_WORD(t32); +
svn commit: r210344 - head/lib/libelf
Author: kaiw Date: Wed Jul 21 11:26:18 2010 New Revision: 210344 URL: http://svn.freebsd.org/changeset/base/210344 Log: Avoid switching between unsigned char and char in the C code generated from libelf_convert.m4. Obtained from:elftoolchain MFC after:1 month Modified: head/lib/libelf/libelf_convert.m4 Modified: head/lib/libelf/libelf_convert.m4 == --- head/lib/libelf/libelf_convert.m4 Wed Jul 21 11:01:40 2010 (r210343) +++ head/lib/libelf/libelf_convert.m4 Wed Jul 21 11:26:18 2010 (r210344) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2006,2007 Joseph Koshy + * Copyright (c) 2006-2008 Joseph Koshy * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -85,22 +85,22 @@ __FBSDID($FreeBSD$); * destination pointer is incremented after the write. */ #defineWRITE_BYTE(P,X) do { \ - unsigned char *const _p = (unsigned char *) (P);\ - _p[0] = (unsigned char) (X); \ + char *const _p = (char *) (P); \ + _p[0] = (char) (X); \ (P) = _p + 1; \ } while (0) #defineWRITE_HALF(P,X) do { \ uint16_t _t = (X); \ - unsigned char *const _p = (unsigned char *) (P);\ - unsigned const char *const _q = (unsigned char *) _t; \ + char *const _p = (char *) (P); \ + const char *const _q = (char *) _t;\ _p[0] = _q[0];\ _p[1] = _q[1];\ (P) = _p + 2; \ } while (0) #defineWRITE_WORD(P,X) do { \ uint32_t _t = (X); \ - unsigned char *const _p = (unsigned char *) (P);\ - unsigned const char *const _q = (unsigned char *) _t; \ + char *const _p = (char *) (P); \ + const char *const _q = (char *) _t;\ _p[0] = _q[0];\ _p[1] = _q[1];\ _p[2] = _q[2];\ @@ -112,8 +112,8 @@ __FBSDID($FreeBSD$); #defineWRITE_SWORD(P,X)WRITE_WORD(P,X) #defineWRITE_WORD64(P,X) do { \ uint64_t _t = (X); \ - unsigned char *const _p = (unsigned char *) (P);\ - unsigned const char *const _q = (unsigned char *) _t; \ + char *const _p = (char *) (P); \ + const char *const _q = (char *) _t;\ _p[0] = _q[0];\ _p[1] = _q[1];\ _p[2] = _q[2];\ @@ -141,16 +141,16 @@ __FBSDID($FreeBSD$); */ #defineREAD_BYTE(P,X) do { \ - const unsigned char *const _p = \ - (const unsigned char *) (P);\ + const char *const _p = \ + (const char *) (P); \ (X) = _p[0];\ (P) = (P) + 1; \ } while (0) #defineREAD_HALF(P,X) do { \ uint16_t _t;\ - unsigned char *const _q = (unsigned char *) _t;\ - const unsigned char *const _p = \ - (const unsigned char *) (P);\ + char *const _q = (char *) _t; \ + const char *const _p = \ + (const char *) (P); \ _q[0] = _p[0];\ _q[1] = _p[1];\ (P) = (P) + 2; \ @@ -158,9 +158,9 @@ __FBSDID($FreeBSD$); } while (0) #defineREAD_WORD(P,X) do { \ uint32_t _t;\ - unsigned
svn commit: r210345 - head/lib/libelf
Author: kaiw Date: Wed Jul 21 12:14:50 2010 New Revision: 210345 URL: http://svn.freebsd.org/changeset/base/210345 Log: * Deprecate `elf_getshnum()`, `elf_getphnum()` and `elf_getshstrndx()` in favour of `elf_getshdrnum()`, `elf_getphdrnum()` and `elf_getshdrstrndx()` respectively. * Add new manual pages for `elf_getshdrstrndx()`, `elf_getphdrnum()` and `elf_getshdrnum()`. * Add a deprecation warning for `elf_getshstrndx()`, `elf_getphnum()` and `elf_getshnum()`. Obtained from:elftoolchain MFC after:1 month Added: head/lib/libelf/elf_getphdrnum.3 (contents, props changed) head/lib/libelf/elf_getshdrnum.3 (contents, props changed) head/lib/libelf/elf_getshdrstrndx.3 (contents, props changed) Modified: head/lib/libelf/Makefile head/lib/libelf/Version.map head/lib/libelf/elf_getphnum.3 head/lib/libelf/elf_getshnum.3 head/lib/libelf/elf_getshstrndx.3 head/lib/libelf/elf_phnum.c head/lib/libelf/elf_shnum.c head/lib/libelf/elf_shstrndx.c head/lib/libelf/libelf.h Modified: head/lib/libelf/Makefile == --- head/lib/libelf/MakefileWed Jul 21 11:26:18 2010(r210344) +++ head/lib/libelf/MakefileWed Jul 21 12:14:50 2010(r210345) @@ -63,7 +63,8 @@ SHLIB_MAJOR= 1 MAN= elf.3 \ elf_begin.3 \ elf_cntl.3 \ - elf_end.3 elf_errmsg.3 \ + elf_end.3 \ + elf_errmsg.3\ elf_fill.3 \ elf_flagdata.3 \ elf_getarhdr.3 \ @@ -72,8 +73,11 @@ MAN= elf.3 \ elf_getdata.3 \ elf_getident.3 \ elf_getscn.3\ + elf_getphdrnum.3\ elf_getphnum.3 \ + elf_getshdrnum.3\ elf_getshnum.3 \ + elf_getshdrstrndx.3 \ elf_getshstrndx.3 \ elf_hash.3 \ elf_kind.3 \ Modified: head/lib/libelf/Version.map == --- head/lib/libelf/Version.map Wed Jul 21 11:26:18 2010(r210344) +++ head/lib/libelf/Version.map Wed Jul 21 12:14:50 2010(r210345) @@ -39,8 +39,11 @@ global: elf_getdata; elf_getident; elf_getscn; + elf_getphdrnum; elf_getphnum; + elf_getshdrnum; elf_getshnum; + elf_getshdrstrndx; elf_getshstrndx; elf_hash; elf_kind; Added: head/lib/libelf/elf_getphdrnum.3 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lib/libelf/elf_getphdrnum.3Wed Jul 21 12:14:50 2010 (r210345) @@ -0,0 +1,86 @@ +.\ 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 +.\ are met: +.\ 1. Redistributions of source code must retain the above copyright +.\notice, this list of conditions and the following disclaimer. +.\ 2. Redistributions in binary form must reproduce the above copyright +.\notice, this list of conditions and the following disclaimer in the +.\documentation and/or other materials provided with the distribution. +.\ +.\ This software is provided by Joseph Koshy ``as is'' and +.\ any express or implied warranties, including, but not limited to, the +.\ implied warranties of merchantability and fitness for a particular purpose +.\ are disclaimed. in no event shall Joseph Koshy be liable +.\ for any direct, indirect, incidental, special, exemplary, or consequential +.\ damages (including, but not limited to, procurement of substitute goods +.\ or services; loss of use, data, or profits; or business interruption) +.\ however caused and on any theory of liability, whether in contract, strict +.\ liability, or tort (including negligence or otherwise) arising in any way +.\ out of the use of this software, even if advised of the possibility of +.\ such damage. +.\ +.\ $FreeBSD$ +.\ +.Dd August 5, 2009 +.Os +.Dt ELF_GETPHDRNUM 3 +.Sh NAME
svn commit: r210347 - head/lib/libelf
Author: kaiw Date: Wed Jul 21 12:30:58 2010 New Revision: 210347 URL: http://svn.freebsd.org/changeset/base/210347 Log: Fix a memory leak. Obtained from:elftoolchain MFC after:1 month Modified: head/lib/libelf/elf_update.c Modified: head/lib/libelf/elf_update.c == --- head/lib/libelf/elf_update.cWed Jul 21 12:23:49 2010 (r210346) +++ head/lib/libelf/elf_update.cWed Jul 21 12:30:58 2010 (r210347) @@ -855,11 +855,13 @@ _libelf_write_elf(Elf *e, off_t newsize) e-e_u.e_elf.e_phdr.e_phdr64 = NULL; } + free(newfile); + return (rc); error: - if (newfile) - free(newfile); + free(newfile); + return ((off_t) -1); } ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r210348 - head/lib/libelf
Author: kaiw Date: Wed Jul 21 12:54:34 2010 New Revision: 210348 URL: http://svn.freebsd.org/changeset/base/210348 Log: Move helper functions `_libelf_ar_get_{name,number,string}()` and `_libelf_ar_open()` to a new compilation unit libelf_ar_util.c to break the circular dependency between elf_memory.o and libelf_ar.o. Obtained from:elftoolchain MFC after:1 month Added: head/lib/libelf/libelf_ar_util.c (contents, props changed) Modified: head/lib/libelf/Makefile head/lib/libelf/_libelf.h head/lib/libelf/libelf_ar.c Modified: head/lib/libelf/Makefile == --- head/lib/libelf/MakefileWed Jul 21 12:30:58 2010(r210347) +++ head/lib/libelf/MakefileWed Jul 21 12:54:34 2010(r210348) @@ -44,6 +44,7 @@ SRCS= elf_begin.c \ libelf_align.c \ libelf_allocate.c \ libelf_ar.c \ + libelf_ar_util.c\ libelf_checksum.c \ libelf_data.c \ libelf_ehdr.c \ Modified: head/lib/libelf/_libelf.h == --- head/lib/libelf/_libelf.h Wed Jul 21 12:30:58 2010(r210347) +++ head/lib/libelf/_libelf.h Wed Jul 21 12:54:34 2010(r210348) @@ -165,6 +165,10 @@ Elf_Scn*_libelf_allocate_scn(Elf *_e, s Elf_Arhdr *_libelf_ar_gethdr(Elf *_e); Elf*_libelf_ar_open(Elf *_e); Elf*_libelf_ar_open_member(int _fd, Elf_Cmd _c, Elf *_ar); +int_libelf_ar_get_member(char *_s, size_t _sz, int _base, size_t *_ret); +char *_libelf_ar_get_string(const char *_buf, size_t _sz, int _rawname); +char *_libelf_ar_get_name(char *_buf, size_t _sz, Elf *_e); +int_libelf_ar_get_number(char *_buf, size_t _sz, int _base, size_t *_ret); Elf_Arsym *_libelf_ar_process_symtab(Elf *_ar, size_t *_dst); unsigned long _libelf_checksum(Elf *_e, int _elfclass); void *_libelf_ehdr(Elf *_e, int _elfclass, int _allocate); Modified: head/lib/libelf/libelf_ar.c == --- head/lib/libelf/libelf_ar.c Wed Jul 21 12:30:58 2010(r210347) +++ head/lib/libelf/libelf_ar.c Wed Jul 21 12:54:34 2010(r210348) @@ -72,145 +72,6 @@ __FBSDID($FreeBSD$); * they must be the very first objects and in that order. */ -/* - * Convert a string bounded by `start' and `start+sz' (exclusive) to a - * number in the specified base. - */ -static int -_libelf_ar_get_number(char *s, size_t sz, int base, size_t *ret) -{ - int c, v; - size_t r; - char *e; - - assert(base = 10); - - e = s + sz; - - /* skip leading blanks */ - for (;s e (c = *s) == ' '; s++) - ; - - r = 0L; - for (;s e; s++) { - if ((c = *s) == ' ') - break; - if (c '0' || c '9') - return (0); - v = c - '0'; - if (v = base) /* Illegal digit. */ - break; - r *= base; - r += v; - } - - *ret = r; - - return (1); -} - -/* - * Retrieve a string from a name field. If `rawname' is set, leave - * ar(1) control characters in. - */ -static char * -_libelf_ar_get_string(const char *buf, size_t bufsize, int rawname) -{ - const char *q; - char *r; - size_t sz; - - if (rawname) - sz = bufsize + 1; - else { - /* Skip back over trailing blanks. */ - for (q = buf + bufsize - 1; q = buf *q == ' '; --q) - ; - - if (q buf) { - /* -* If the input buffer only had blanks in it, -* return a zero-length string. -*/ - buf = ; - sz = 1; - } else { - /* -* Remove the trailing '/' character, but only -* if the name isn't one of the special names -* / and //. -*/ - if (q buf + 1 || - (q == (buf + 1) *buf != '/')) - q--; - - sz = q - buf + 2; /* Space for a trailing NUL. */ - } - } - - if ((r = malloc(sz)) == NULL) { - LIBELF_SET_ERROR(RESOURCE, 0); - return (NULL); - } - - (void) strncpy(r, buf, sz); - r[sz - 1] = '\0'; - - return (r); -} - -/* - * Retrieve
svn commit: r210349 - head/lib/libelf
Author: kaiw Date: Wed Jul 21 13:00:01 2010 New Revision: 210349 URL: http://svn.freebsd.org/changeset/base/210349 Log: Remove a redundant word. Obtained from:elftoolchain MFC after:1 month Modified: head/lib/libelf/elf.3 Modified: head/lib/libelf/elf.3 == --- head/lib/libelf/elf.3 Wed Jul 21 12:54:34 2010(r210348) +++ head/lib/libelf/elf.3 Wed Jul 21 13:00:01 2010(r210349) @@ -36,8 +36,8 @@ .Sh DESCRIPTION The .Lb libelf -library provides functions that allow an application to read and -manipulate ELF object files, and to read +provides functions that allow an application to read and manipulate +ELF object files, and to read .Xr ar 1 archives. The library allows the manipulation of ELF objects in a byte ordering ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r210351 - head/lib/libelf
Author: kaiw Date: Wed Jul 21 13:18:57 2010 New Revision: 210351 URL: http://svn.freebsd.org/changeset/base/210351 Log: * Note that ar(1) archives may also be opened using `elf_memory(3)`. * Ignore the passed in value of the `fd` argument for ar(1) archives opened with elf_memory(3). Obtained from:elftoolchain MFC after:1 month Modified: head/lib/libelf/elf_begin.3 head/lib/libelf/elf_begin.c Modified: head/lib/libelf/elf_begin.3 == --- head/lib/libelf/elf_begin.3 Wed Jul 21 13:01:21 2010(r210350) +++ head/lib/libelf/elf_begin.3 Wed Jul 21 13:18:57 2010(r210351) @@ -23,7 +23,7 @@ .\ .\ $FreeBSD$ .\ -.Dd June 21, 2006 +.Dd April 11, 2010 .Dt ELF_BEGIN 3 .Os .Sh NAME @@ -163,7 +163,9 @@ archive may be opened in read mode (with set to .Dv ELF_C_READ ) using -.Fn elf_begin . +.Fn elf_begin +or +.Fn elf_memory . The returned ELF descriptor can be passed into to subsequent calls to .Fn elf_begin Modified: head/lib/libelf/elf_begin.c == --- head/lib/libelf/elf_begin.c Wed Jul 21 13:01:21 2010(r210350) +++ head/lib/libelf/elf_begin.c Wed Jul 21 13:18:57 2010(r210351) @@ -131,13 +131,15 @@ elf_begin(int fd, Elf_Cmd c, Elf *a) case ELF_C_READ: /* * Descriptor `a' could be for a regular ELF file, or -* for an ar(1) archive. +* for an ar(1) archive. If descriptor `a' was opened +* using a valid file descriptor, we need to check if +* the passed in `fd' value matches the original one. */ - if (a (a-e_fd != fd || c != a-e_cmd)) { + if (a + ((a-e_fd != -1 a-e_fd != fd) || c != a-e_cmd)) { LIBELF_SET_ERROR(ARGUMENT, 0); return (NULL); } - break; default: @@ -149,7 +151,7 @@ elf_begin(int fd, Elf_Cmd c, Elf *a) if (a == NULL) e = _libelf_open_object(fd, c); else if (a-e_kind == ELF_K_AR) - e = _libelf_ar_open_member(fd, c, a); + e = _libelf_ar_open_member(a-e_fd, c, a); else (e = a)-e_activations++; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r210352 - head/lib/libelf
Author: kaiw Date: Wed Jul 21 13:23:07 2010 New Revision: 210352 URL: http://svn.freebsd.org/changeset/base/210352 Log: Add a cross-reference to `elf_rawfile(3)`. Obtained from:elftoolchain MFC after:1 month Modified: head/lib/libelf/elf_getdata.3 Modified: head/lib/libelf/elf_getdata.3 == --- head/lib/libelf/elf_getdata.3 Wed Jul 21 13:18:57 2010 (r210351) +++ head/lib/libelf/elf_getdata.3 Wed Jul 21 13:23:07 2010 (r210352) @@ -1,4 +1,4 @@ -.\ Copyright (c) 2006,2008 Joseph Koshy. All rights reserved. +.\ Copyright (c) 2006,2008,2010 Joseph Koshy. All rights reserved. .\ .\ Redistribution and use in source and binary forms, with or without .\ modification, are permitted provided that the following conditions @@ -23,7 +23,7 @@ .\ .\ $FreeBSD$ .\ -.Dd August 26, 2006 +.Dd April 30, 2010 .Dt ELF_GETDATA 3 .Os .Sh NAME @@ -193,6 +193,7 @@ An out of memory condition was detected. .Xr elf_getscn 3 , .Xr elf_getshdr 3 , .Xr elf_newscn 3 , +.Xr elf_rawfile 3 , .Xr elf_update 3 , .Xr elf_version 3 , .Xr gelf 3 ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r210353 - head/lib/libelf
Author: kaiw Date: Wed Jul 21 13:29:00 2010 New Revision: 210353 URL: http://svn.freebsd.org/changeset/base/210353 Log: * Remove a superfluous error description. * Document an additional error that may be returned: `ELF_E_ARCHIVE`. Obtained from:elftoolchain MFC after:1 month Modified: head/lib/libelf/elf_begin.3 Modified: head/lib/libelf/elf_begin.3 == --- head/lib/libelf/elf_begin.3 Wed Jul 21 13:23:07 2010(r210352) +++ head/lib/libelf/elf_begin.3 Wed Jul 21 13:29:00 2010(r210353) @@ -23,7 +23,7 @@ .\ .\ $FreeBSD$ .\ -.Dd April 11, 2010 +.Dd June 20, 2010 .Dt ELF_BEGIN 3 .Os .Sh NAME @@ -224,6 +224,10 @@ Function can fail with the following errors: .Pp .Bl -tag -width [ELF_E_RESOURCE] +.It Bq Er ELF_E_ARCHIVE +The archive denoted by argument +.Ar elf +could not be parsed. .It Bq Er ELF_E_ARGUMENT An unrecognized value was specified in argument .Ar cmd . @@ -247,12 +251,6 @@ differs from the value specified when EL .Ar elf was created. .It Bq Er ELF_E_ARGUMENT -Argument -.Ar elf -was not a descriptor for an -.Xr ar 1 -archive. -.It Bq Er ELF_E_ARGUMENT An .Xr ar 1 archive was opened with with ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r209393 - stable/8/lib/libelf
Author: kaiw Date: Mon Jun 21 13:47:29 2010 New Revision: 209393 URL: http://svn.freebsd.org/changeset/base/209393 Log: MFC r209122: * Improve compatibility with existing application code by permitting the use of `elf_getbase()` on non-archive members. This change is needed for gcc LTO (-flto) to work properly. * Style fix: paranthesize returned values. * Document the current behaviour of `elf_getbase()`. Modified: stable/8/lib/libelf/elf_getbase.3 stable/8/lib/libelf/elf_getbase.c Directory Properties: stable/8/lib/libelf/ (props changed) Modified: stable/8/lib/libelf/elf_getbase.3 == --- stable/8/lib/libelf/elf_getbase.3 Mon Jun 21 12:50:54 2010 (r209392) +++ stable/8/lib/libelf/elf_getbase.3 Mon Jun 21 13:47:29 2010 (r209393) @@ -1,4 +1,4 @@ -.\ Copyright (c) 2006 Joseph Koshy. All rights reserved. +.\ Copyright (c) 2006,2008,2010 Joseph Koshy. All rights reserved. .\ .\ Redistribution and use in source and binary forms, with or without .\ modification, are permitted provided that the following conditions @@ -23,7 +23,7 @@ .\ .\ $FreeBSD$ .\ -.Dd June 11, 2006 +.Dd June 6, 2010 .Os .Dt ELF_GETBASE 3 .Sh NAME @@ -38,17 +38,21 @@ .Sh DESCRIPTION Function .Fn elf_getbase -returns the file offset in the containing archive of the first byte of -the file referenced by ELF descriptor +returns the file offset to the first byte of the object referenced by ELF +descriptor .Ar elf . +.Pp +For descriptors referencing members of archives, the returned offset is +the file offset of the member in its containing archive. +For descriptors to regular objects, the returned offset is (vacuously) +zero. .Sh RETURN VALUES Function .Fn elf_getbase -returns a valid file offset into the containing archive if successful. -It returns -1 if argument -.Ar elf -is NULL or is not a member of an -archive. +returns a valid file offset if successful, or +.Pq Vt off_t +.Li -1 +in case of an error. .Sh ERRORS Function .Fn elf_getbase @@ -57,7 +61,7 @@ may fail with the following errors: .It Bq Er ELF_E_ARGUMENT Argument .Ar elf -is not an ELF descriptor for an archive member. +was NULL. .El .Sh SEE ALSO .Xr elf 3 , Modified: stable/8/lib/libelf/elf_getbase.c == --- stable/8/lib/libelf/elf_getbase.c Mon Jun 21 12:50:54 2010 (r209392) +++ stable/8/lib/libelf/elf_getbase.c Mon Jun 21 13:47:29 2010 (r209393) @@ -34,12 +34,14 @@ __FBSDID($FreeBSD$); off_t elf_getbase(Elf *e) { - if (e == NULL || - e-e_parent == NULL) { + if (e == NULL) { LIBELF_SET_ERROR(ARGUMENT, 0); - return (off_t) -1; + return ((off_t) -1); } + if (e-e_parent == NULL) + return ((off_t) 0); + return ((off_t) ((uintptr_t) e-e_rawfile - (uintptr_t) e-e_parent-e_rawfile)); } ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r209394 - stable/7/lib/libelf
Author: kaiw Date: Mon Jun 21 13:52:31 2010 New Revision: 209394 URL: http://svn.freebsd.org/changeset/base/209394 Log: MFC r209122: * Improve compatibility with existing application code by permitting the use of `elf_getbase()` on non-archive members. This change is needed for gcc LTO (-flto) to work properly. * Style fix: paranthesize returned values. * Document the current behaviour of `elf_getbase()`. Modified: stable/7/lib/libelf/elf_getbase.3 stable/7/lib/libelf/elf_getbase.c Directory Properties: stable/7/lib/libelf/ (props changed) Modified: stable/7/lib/libelf/elf_getbase.3 == --- stable/7/lib/libelf/elf_getbase.3 Mon Jun 21 13:47:29 2010 (r209393) +++ stable/7/lib/libelf/elf_getbase.3 Mon Jun 21 13:52:31 2010 (r209394) @@ -1,4 +1,4 @@ -.\ Copyright (c) 2006 Joseph Koshy. All rights reserved. +.\ Copyright (c) 2006,2008,2010 Joseph Koshy. All rights reserved. .\ .\ Redistribution and use in source and binary forms, with or without .\ modification, are permitted provided that the following conditions @@ -23,7 +23,7 @@ .\ .\ $FreeBSD$ .\ -.Dd June 11, 2006 +.Dd June 6, 2010 .Os .Dt ELF_GETBASE 3 .Sh NAME @@ -38,17 +38,21 @@ .Sh DESCRIPTION Function .Fn elf_getbase -returns the file offset in the containing archive of the first byte of -the file referenced by ELF descriptor +returns the file offset to the first byte of the object referenced by ELF +descriptor .Ar elf . +.Pp +For descriptors referencing members of archives, the returned offset is +the file offset of the member in its containing archive. +For descriptors to regular objects, the returned offset is (vacuously) +zero. .Sh RETURN VALUES Function .Fn elf_getbase -returns a valid file offset into the containing archive if successful. -It returns -1 if argument -.Ar elf -is NULL or is not a member of an -archive. +returns a valid file offset if successful, or +.Pq Vt off_t +.Li -1 +in case of an error. .Sh ERRORS Function .Fn elf_getbase @@ -57,7 +61,7 @@ may fail with the following errors: .It Bq Er ELF_E_ARGUMENT Argument .Ar elf -is not an ELF descriptor for an archive member. +was NULL. .El .Sh SEE ALSO .Xr elf 3 , Modified: stable/7/lib/libelf/elf_getbase.c == --- stable/7/lib/libelf/elf_getbase.c Mon Jun 21 13:47:29 2010 (r209393) +++ stable/7/lib/libelf/elf_getbase.c Mon Jun 21 13:52:31 2010 (r209394) @@ -34,12 +34,14 @@ __FBSDID($FreeBSD$); off_t elf_getbase(Elf *e) { - if (e == NULL || - e-e_parent == NULL) { + if (e == NULL) { LIBELF_SET_ERROR(ARGUMENT, 0); - return (off_t) -1; + return ((off_t) -1); } + if (e-e_parent == NULL) + return ((off_t) 0); + return ((off_t) ((uintptr_t) e-e_rawfile - (uintptr_t) e-e_parent-e_rawfile)); } ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r209122 - head/lib/libelf
Author: kaiw Date: Sun Jun 13 10:58:50 2010 New Revision: 209122 URL: http://svn.freebsd.org/changeset/base/209122 Log: * Improve compatibility with existing application code by permitting the use of `elf_getbase()` on non-archive members. This change is needed for gcc LTO (-flto) to work properly. * Style fix: paranthesize returned values. * Document the current behaviour of `elf_getbase()`. Tested by:gerald, Steve Kargl (original patch) Obtained from:elftoolchain MFC after:3 days Modified: head/lib/libelf/elf_getbase.3 head/lib/libelf/elf_getbase.c Modified: head/lib/libelf/elf_getbase.3 == --- head/lib/libelf/elf_getbase.3 Sun Jun 13 07:30:51 2010 (r209121) +++ head/lib/libelf/elf_getbase.3 Sun Jun 13 10:58:50 2010 (r209122) @@ -1,4 +1,4 @@ -.\ Copyright (c) 2006 Joseph Koshy. All rights reserved. +.\ Copyright (c) 2006,2008,2010 Joseph Koshy. All rights reserved. .\ .\ Redistribution and use in source and binary forms, with or without .\ modification, are permitted provided that the following conditions @@ -23,7 +23,7 @@ .\ .\ $FreeBSD$ .\ -.Dd June 11, 2006 +.Dd June 6, 2010 .Dt ELF_GETBASE 3 .Os .Sh NAME @@ -38,17 +38,21 @@ .Sh DESCRIPTION Function .Fn elf_getbase -returns the file offset in the containing archive of the first byte of -the file referenced by ELF descriptor +returns the file offset to the first byte of the object referenced by ELF +descriptor .Ar elf . +.Pp +For descriptors referencing members of archives, the returned offset is +the file offset of the member in its containing archive. +For descriptors to regular objects, the returned offset is (vacuously) +zero. .Sh RETURN VALUES Function .Fn elf_getbase -returns a valid file offset into the containing archive if successful. -It returns -1 if argument -.Ar elf -is NULL or is not a member of an -archive. +returns a valid file offset if successful, or +.Pq Vt off_t +.Li -1 +in case of an error. .Sh ERRORS Function .Fn elf_getbase @@ -57,7 +61,7 @@ may fail with the following errors: .It Bq Er ELF_E_ARGUMENT Argument .Ar elf -is not an ELF descriptor for an archive member. +was NULL. .El .Sh SEE ALSO .Xr elf 3 , Modified: head/lib/libelf/elf_getbase.c == --- head/lib/libelf/elf_getbase.c Sun Jun 13 07:30:51 2010 (r209121) +++ head/lib/libelf/elf_getbase.c Sun Jun 13 10:58:50 2010 (r209122) @@ -34,12 +34,14 @@ __FBSDID($FreeBSD$); off_t elf_getbase(Elf *e) { - if (e == NULL || - e-e_parent == NULL) { + if (e == NULL) { LIBELF_SET_ERROR(ARGUMENT, 0); - return (off_t) -1; + return ((off_t) -1); } + if (e-e_parent == NULL) + return ((off_t) 0); + return ((off_t) ((uintptr_t) e-e_rawfile - (uintptr_t) e-e_parent-e_rawfile)); } ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
Re: svn commit: r209122 - head/lib/libelf
On Sun, Jun 13, 2010 at 09:37:10AM -0700, Steve Kargl wrote: On Sun, Jun 13, 2010 at 10:58:50AM +, Kai Wang wrote: Author: kaiw Date: Sun Jun 13 10:58:50 2010 New Revision: 209122 URL: http://svn.freebsd.org/changeset/base/209122 Log: * Improve compatibility with existing application code by permitting the use of `elf_getbase()` on non-archive members. This change is needed for gcc LTO (-flto) to work properly. * Style fix: paranthesize returned values. * Document the current behaviour of `elf_getbase()`. Tested by:gerald, Steve Kargl (original patch) Obtained from:elftoolchain MFC after:3 days Modified: head/lib/libelf/elf_getbase.3 head/lib/libelf/elf_getbase.c Thanks. Unfortunately without the patch to elf_update.c, gcc LTO will not work (ie., 'gcc -flto -o z a.o b.o' will segfault). Any chance that the elf_update.c patch will be committed; possibly as a conditional compilation. The patch to elf_update.c needs some more work before it can be committed. We've concluded that our libelf is indeed overly strict about data alignment inside sections, so the problem will be fixed eventually. A ticket[1] has been created to track this issue. Thanks, Kai [1] http://sourceforge.net/apps/trac/elftoolchain/ticket/264 ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r208262 - in stable/8: lib/libusbhid usr.sbin/bluetooth/bthidd
Author: kaiw Date: Tue May 18 10:32:20 2010 New Revision: 208262 URL: http://svn.freebsd.org/changeset/base/208262 Log: MFC r205728 Merge improvements from kernel HID parser to the userland usbhid(3) parser. This merge does not change any API and should not break any native or thirdparty applications. Changes include: * Merge multiple report ID support and other improvements from kernel HID parser. * Ignore rid argument in hid_start_parser, parse all the report items since we now support multiple report ID. * Skip report ID byte in hid_get_data() and set report ID byte in hid_set_data(), if report ID is non-zero. * Reimplement hid_get_report_id: instead get report id from uhid device (which is always 0), try parsing the report descriptor and return the first report ID encountered. MFC r207812 hid_get_data() now expects that the hid data passed in always contains the report ID byte. Thus we should not skip the the report ID byte in hid_interrupt(). Also, if HUP_KEYBOARD usage is an array, do not try to modify the 'data' pointer, instead, increase the hid_item_t field 'pos' by 'report_size' before calling hid_get_data() during each iteration. Modified: stable/8/lib/libusbhid/data.c stable/8/lib/libusbhid/descr.c stable/8/lib/libusbhid/parse.c stable/8/lib/libusbhid/usage.c stable/8/lib/libusbhid/usbhid.h stable/8/lib/libusbhid/usbvar.h stable/8/usr.sbin/bluetooth/bthidd/hid.c Directory Properties: stable/8/lib/libusbhid/ (props changed) stable/8/usr.sbin/bluetooth/ (props changed) Modified: stable/8/lib/libusbhid/data.c == --- stable/8/lib/libusbhid/data.c Tue May 18 10:24:23 2010 (r208261) +++ stable/8/lib/libusbhid/data.c Tue May 18 10:32:20 2010 (r208262) @@ -29,6 +29,7 @@ #include sys/cdefs.h __FBSDID($FreeBSD$); +#include sys/param.h #include assert.h #include stdlib.h #include usbhid.h @@ -36,18 +37,27 @@ __FBSDID($FreeBSD$); int32_t hid_get_data(const void *p, const hid_item_t *h) { - const unsigned char *buf; - unsigned int hpos; - unsigned int hsize; - int data; + const uint8_t *buf; + uint32_t hpos; + uint32_t hsize; + uint32_t data; int i, end, offs; buf = p; + + /* Skip report ID byte. */ + if (h-report_ID 0) + buf++; + hpos = h-pos; /* bit position of data */ hsize = h-report_size; /* bit length of data */ + /* Range check and limit */ if (hsize == 0) return (0); + if (hsize 32) + hsize = 32; + offs = hpos / 8; end = (hpos + hsize) / 8 - offs; data = 0; @@ -70,15 +80,20 @@ hid_get_data(const void *p, const hid_it void hid_set_data(void *p, const hid_item_t *h, int32_t data) { - unsigned char *buf; - unsigned int hpos; - unsigned int hsize; + uint8_t *buf; + uint32_t hpos; + uint32_t hsize; uint32_t mask; int i; int end; int offs; buf = p; + + /* Set report ID byte. */ + if (h-report_ID 0) + *buf++ = h-report_ID 0xff; + hpos = h-pos; /* bit position of data */ hsize = h-report_size; /* bit length of data */ @@ -97,5 +112,5 @@ hid_set_data(void *p, const hid_item_t * for (i = 0; i = end; i++) buf[offs + i] = (buf[offs + i] (mask (i*8))) | - ((data (i*8)) 0xff); + ((data (i*8)) 0xff); } Modified: stable/8/lib/libusbhid/descr.c == --- stable/8/lib/libusbhid/descr.c Tue May 18 10:24:23 2010 (r208261) +++ stable/8/lib/libusbhid/descr.c Tue May 18 10:32:20 2010 (r208262) @@ -38,7 +38,6 @@ __FBSDID($FreeBSD$); #include unistd.h #include sys/time.h #include sys/ioctl.h - #include dev/usb/usb_ioctl.h #include usbhid.h @@ -59,9 +58,30 @@ hid_set_immed(int fd, int enable) int hid_get_report_id(int fd) { + report_desc_t rep; + hid_data_t d; + hid_item_t h; + int kindset; int temp = -1; int ret; + if ((rep = hid_get_report_desc(fd)) == NULL) + goto use_ioctl; + kindset = 1 hid_input | 1 hid_output | 1 hid_feature; + for (d = hid_start_parse(rep, kindset, 0); hid_get_item(d, h); ) { + /* Return the first report ID we met. */ + if (h.report_ID != 0) { + temp = h.report_ID; + break; + } + } + hid_end_parse(d); + hid_dispose_report_desc(rep); + + if (temp 0) + return (temp); + +use_ioctl: ret = ioctl(fd, USB_GET_REPORT_ID,
svn commit: r208189 - head/usr.bin/ar
Author: kaiw Date: Mon May 17 09:37:59 2010 New Revision: 208189 URL: http://svn.freebsd.org/changeset/base/208189 Log: Removed ar(1)'s support for compressed archives. This change removes ar(1)'s dependencies on compressor libraries -lz, -lbz2 and -llzma and fixes building HEAD on some versions of FreeBSD[78]. Option -j and -z is now accepted but ignored. Compressed ar(1) archives are not useful without a ld(1) that can read them. Also, the current ar(1) compression scheme prevents random access of archive members and needs to be redesigned anyway. Submitted by: kientzle (original patch) Reviewed by: delphij Discussed on: -current mailing list Modified: head/usr.bin/ar/Makefile head/usr.bin/ar/acpyacc.y head/usr.bin/ar/ar.1 head/usr.bin/ar/ar.c head/usr.bin/ar/ar.h head/usr.bin/ar/read.c head/usr.bin/ar/write.c Modified: head/usr.bin/ar/Makefile == --- head/usr.bin/ar/MakefileMon May 17 08:46:27 2010(r208188) +++ head/usr.bin/ar/MakefileMon May 17 09:37:59 2010(r208189) @@ -3,8 +3,8 @@ PROG= ar SRCS= ar.c acplex.l acpyacc.y read.c util.c write.c y.tab.h -DPADD= ${LIBARCHIVE} ${LIBBZ2} ${LIBZ} ${LIBLZMA} ${LIBELF} -LDADD= -larchive -lbz2 -lz -llzma -lelf +DPADD= ${LIBARCHIVE} ${LIBELF} +LDADD= -larchive -lelf CFLAGS+=-I. -I${.CURDIR} Modified: head/usr.bin/ar/acpyacc.y == --- head/usr.bin/ar/acpyacc.y Mon May 17 08:46:27 2010(r208188) +++ head/usr.bin/ar/acpyacc.y Mon May 17 09:37:59 2010(r208189) @@ -250,7 +250,7 @@ arscp_open(char *fname) if ((a = archive_read_new()) == NULL) bsdar_errc(bsdar, EX_SOFTWARE, 0, archive_read_new failed); - archive_read_support_compression_all(a); + archive_read_support_compression_none(a); archive_read_support_format_ar(a); AC(archive_read_open_file(a, fname, DEF_BLKSZ)); if ((r = archive_read_next_header(a, entry))) Modified: head/usr.bin/ar/ar.1 == --- head/usr.bin/ar/ar.1Mon May 17 08:46:27 2010(r208188) +++ head/usr.bin/ar/ar.1Mon May 17 09:37:59 2010(r208189) @@ -23,7 +23,7 @@ .\ .\ $FreeBSD$ .\ -.Dd August 31, 2007 +.Dd May 17, 2010 .Dt AR 1 .Os .Sh NAME @@ -186,8 +186,7 @@ Synonymous with option Synonymous with option .Fl b . .It Fl j -Compress the resulting archive with -.Xr bzip2 1 . +This option is accepted but ignored. .It Fl m Move archive members specified by arguments .Ar files ... @@ -344,8 +343,7 @@ of extraction unless the .Fl o option was specified. .It Fl z -Compress the resulting archive with -.Xr gzip 1 . +This option is accepted but ignored. .El .Sh EXAMPLES To create a new archive Modified: head/usr.bin/ar/ar.c == --- head/usr.bin/ar/ar.cMon May 17 08:46:27 2010(r208188) +++ head/usr.bin/ar/ar.cMon May 17 09:37:59 2010(r208189) @@ -178,7 +178,7 @@ main(int argc, char **argv) bsdar-options |= AR_TR; break; case 'j': - bsdar-options |= AR_J; + /* ignored */ break; case 'l': /* ignored, for GNU ar comptibility */ @@ -223,7 +223,7 @@ main(int argc, char **argv) set_mode(bsdar, opt); break; case 'z': - bsdar-options |= AR_Z; + /* ignored */ break; case OPTION_HELP: bsdar_usage(); Modified: head/usr.bin/ar/ar.h == --- head/usr.bin/ar/ar.hMon May 17 08:46:27 2010(r208188) +++ head/usr.bin/ar/ar.hMon May 17 09:37:59 2010(r208189) @@ -81,7 +81,6 @@ struct bsdar { const char *addlib; /* target of ADDLIB. */ const char *posarg; /* position arg for modifiers -a, -b. */ char mode; /* program mode */ - char compression; /* compression mode */ int options; /* command line options */ const char *progname; /* program name */ Modified: head/usr.bin/ar/read.c == --- head/usr.bin/ar/read.c Mon May 17 08:46:27 2010(r208188) +++ head/usr.bin/ar/read.c Mon May 17 09:37:59 2010(r208189) @@ -87,7 +87,7 @@ read_archive(struct bsdar *bsdar, char m if ((a = archive_read_new()) == NULL) bsdar_errc(bsdar, EX_SOFTWARE, 0,
svn commit: r207812 - head/usr.sbin/bluetooth/bthidd
Author: kaiw Date: Sun May 9 09:20:25 2010 New Revision: 207812 URL: http://svn.freebsd.org/changeset/base/207812 Log: Catch up with libusbhid merge (rev 205728). hid_get_data() now expects that the hid data passed in always contains the report ID byte. Thus we should not skip the the report ID byte in hid_interrupt(). Also, if HUP_KEYBOARD usage is an array, do not try to modify the 'data' pointer, instead, increase the hid_item_t field 'pos' by 'report_size' before calling hid_get_data() during each iteration. PR: usb/146367 Reported and tested by: Alex Deiter Pointy hat to:kaiw Reviewed by: emax Modified: head/usr.sbin/bluetooth/bthidd/hid.c Modified: head/usr.sbin/bluetooth/bthidd/hid.c == --- head/usr.sbin/bluetooth/bthidd/hid.cSun May 9 08:22:33 2010 (r207811) +++ head/usr.sbin/bluetooth/bthidd/hid.cSun May 9 09:20:25 2010 (r207812) @@ -130,7 +130,7 @@ hid_interrupt(bthid_session_p s, uint8_t hid_item_t h; int32_t report_id, usage, page, val, mouse_x, mouse_y, mouse_z, mouse_butt, - mevents, kevents; + mevents, kevents, i; assert(s != NULL); assert(s-srv != NULL); @@ -150,8 +150,8 @@ hid_interrupt(bthid_session_p s, uint8_t } report_id = data[1]; - data += 2; - len -= 2; + data ++; + len --; hid_device = get_hid_device(s-bdaddr); assert(hid_device != NULL); @@ -202,17 +202,11 @@ hid_interrupt(bthid_session_p s, uint8_t if (val val kbd_maxkey()) bit_set(s-keys1, val); - data ++; - len --; - - len = min(len, h.report_size); - while (len 0) { + for (i = 1; i h.report_count; i++) { + h.pos += h.report_size; val = hid_get_data(data, h); if (val val kbd_maxkey()) bit_set(s-keys1, val); - - data ++; - len --; } } break; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r205728 - head/lib/libusbhid
Author: kaiw Date: Sat Mar 27 08:00:16 2010 New Revision: 205728 URL: http://svn.freebsd.org/changeset/base/205728 Log: Merge improvements from kernel HID parser to the userland usbhid(3) parser. This merge does not change any API and should not break any native or thirdparty applications. Changes include: * Merge multiple report ID support and other improvements from kernel HID parser. * Ignore rid argument in hid_start_parser, parse all the report items since we now support multiple report ID. * Skip report ID byte in hid_get_data() and set report ID byte in hid_set_data(), if report ID is non-zero. * Reimplement hid_get_report_id: instead get report id from uhid device (which is always 0), try parsing the report descriptor and return the first report ID encountered. Reviewed by: hps Silent on:-usb mailing list Modified: head/lib/libusbhid/data.c head/lib/libusbhid/descr.c head/lib/libusbhid/parse.c head/lib/libusbhid/usage.c head/lib/libusbhid/usbhid.h head/lib/libusbhid/usbvar.h Modified: head/lib/libusbhid/data.c == --- head/lib/libusbhid/data.c Sat Mar 27 06:53:11 2010(r205727) +++ head/lib/libusbhid/data.c Sat Mar 27 08:00:16 2010(r205728) @@ -29,6 +29,7 @@ #include sys/cdefs.h __FBSDID($FreeBSD$); +#include sys/param.h #include assert.h #include stdlib.h #include usbhid.h @@ -36,18 +37,27 @@ __FBSDID($FreeBSD$); int hid_get_data(const void *p, const hid_item_t *h) { - const unsigned char *buf; - unsigned int hpos; - unsigned int hsize; - int data; + const uint8_t *buf; + uint32_t hpos; + uint32_t hsize; + uint32_t data; int i, end, offs; buf = p; + + /* Skip report ID byte. */ + if (h-report_ID 0) + buf++; + hpos = h-pos; /* bit position of data */ hsize = h-report_size; /* bit length of data */ + /* Range check and limit */ if (hsize == 0) return (0); + if (hsize 32) + hsize = 32; + offs = hpos / 8; end = (hpos + hsize) / 8 - offs; data = 0; @@ -66,12 +76,17 @@ hid_get_data(const void *p, const hid_it void hid_set_data(void *p, const hid_item_t *h, int data) { - unsigned char *buf; - unsigned int hpos; - unsigned int hsize; + uint8_t *buf; + uint32_t hpos; + uint32_t hsize; int i, end, offs, mask; buf = p; + + /* Set report ID byte. */ + if (h-report_ID 0) + *buf++ = h-report_ID 0xff; + hpos = h-pos; /* bit position of data */ hsize = h-report_size; /* bit length of data */ @@ -90,5 +105,5 @@ hid_set_data(void *p, const hid_item_t * for (i = 0; i = end; i++) buf[offs + i] = (buf[offs + i] (mask (i*8))) | - ((data (i*8)) 0xff); + ((data (i*8)) 0xff); } Modified: head/lib/libusbhid/descr.c == --- head/lib/libusbhid/descr.c Sat Mar 27 06:53:11 2010(r205727) +++ head/lib/libusbhid/descr.c Sat Mar 27 08:00:16 2010(r205728) @@ -38,7 +38,6 @@ __FBSDID($FreeBSD$); #include unistd.h #include sys/time.h #include sys/ioctl.h - #include dev/usb/usb_ioctl.h #include usbhid.h @@ -59,9 +58,30 @@ hid_set_immed(int fd, int enable) int hid_get_report_id(int fd) { + report_desc_t rep; + hid_data_t d; + hid_item_t h; + int kindset; int temp = -1; int ret; + if ((rep = hid_get_report_desc(fd)) == NULL) + goto use_ioctl; + kindset = 1 hid_input | 1 hid_output | 1 hid_feature; + for (d = hid_start_parse(rep, kindset, 0); hid_get_item(d, h); ) { + /* Return the first report ID we met. */ + if (h.report_ID != 0) { + temp = h.report_ID; + break; + } + } + hid_end_parse(d); + hid_dispose_report_desc(rep); + + if (temp 0) + return (temp); + +use_ioctl: ret = ioctl(fd, USB_GET_REPORT_ID, temp); #ifdef HID_COMPAT7 if (ret 0) Modified: head/lib/libusbhid/parse.c == --- head/lib/libusbhid/parse.c Sat Mar 27 06:53:11 2010(r205727) +++ head/lib/libusbhid/parse.c Sat Mar 27 08:00:16 2010(r205728) @@ -40,42 +40,43 @@ __FBSDID($FreeBSD$); #include usbhid.h #include usbvar.h -#define MAXUSAGE 100 -struct hid_data { - u_char *start; - u_char *end; - u_char *p; - hid_item_t cur; - unsigned int usages[MAXUSAGE]; - int nusage; - int minset; - int logminsize; - int multi; - int multimax;
svn commit: r190904 - head/sys/sys
Author: kaiw Date: Fri Apr 10 21:24:18 2009 New Revision: 190904 URL: http://svn.freebsd.org/changeset/base/190904 Log: Added DT_GNU_HASH entry for GNU-style hash table. Modified: head/sys/sys/elf_common.h Modified: head/sys/sys/elf_common.h == --- head/sys/sys/elf_common.h Fri Apr 10 19:16:14 2009(r190903) +++ head/sys/sys/elf_common.h Fri Apr 10 21:24:18 2009(r190904) @@ -427,6 +427,7 @@ typedef struct { * built, these entries will need to be adjusted. */ #defineDT_ADDRRNGLO0x6e00 +#defineDT_GNU_HASH 0x6ef5 /* GNU-style hash table */ #defineDT_CONFIG 0x6efa /* configuration information */ #defineDT_DEPAUDIT 0x6efb /* dependency auditing */ #defineDT_AUDIT0x6efc /* object auditing */ ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r188472 - in head/sys/dev: ppc uart
Author: kaiw Date: Wed Feb 11 00:08:03 2009 New Revision: 188472 URL: http://svn.freebsd.org/changeset/base/188472 Log: Added entries for Lava SP-PCI (1 serial + 1 parallel) PCI card. The card is a multifunction PCI and report itself as two logical devices. Modified: head/sys/dev/ppc/ppc_pci.c head/sys/dev/uart/uart_bus_pci.c Modified: head/sys/dev/ppc/ppc_pci.c == --- head/sys/dev/ppc/ppc_pci.c Wed Feb 11 00:01:02 2009(r188471) +++ head/sys/dev/ppc/ppc_pci.c Wed Feb 11 00:08:03 2009(r188472) @@ -84,6 +84,7 @@ struct pci_id { static struct pci_id pci_ids[] = { { 0x1020131f, SIIG Cyber Parallel PCI (10x family), 0x18 }, { 0x2020131f, SIIG Cyber Parallel PCI (20x family), 0x10 }, + { 0x05111407, Lava SP BIDIR Parallel PCI, 0x10 }, { 0x80001407, Lava Computers 2SP-PCI parallel port, 0x10 }, { 0x84031415, Oxford Semiconductor OX12PCI840 Parallel port, 0x10 }, { 0x95131415, Oxford Semiconductor OX16PCI954 Parallel port, 0x10 }, Modified: head/sys/dev/uart/uart_bus_pci.c == --- head/sys/dev/uart/uart_bus_pci.cWed Feb 11 00:01:02 2009 (r188471) +++ head/sys/dev/uart/uart_bus_pci.cWed Feb 11 00:08:03 2009 (r188472) @@ -96,6 +96,7 @@ static struct pci_id pci_ns8250_ids[] = 0x18 }, { 0x1407, 0x0110, 0x, 0, Lava Computer mfg DSerial-PCI Port A, 0x10 }, { 0x1407, 0x0111, 0x, 0, Lava Computer mfg DSerial-PCI Port B, 0x10 }, +{ 0x1407, 0x0510, 0x, 0, Lava SP Serial 550 PCI, 0x10 }, { 0x1409, 0x7168, 0x1409, 0x4025, Timedia Technology Serial Port, 0x10, 8 * DEFAULT_RCLK }, { 0x1409, 0x7168, 0x1409, 0x4027, Timedia Technology Serial Port, 0x10, ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r186720 - head/sys/sys
Author: kaiw Date: Sat Jan 3 13:42:49 2009 New Revision: 186720 URL: http://svn.freebsd.org/changeset/base/186720 Log: Added section type SHT_GNU_HASH. GNU-style .hash section is a new style of hash section with better performace than the original SYSV hash. It can be generated by newer binutils. Modified: head/sys/sys/elf_common.h Modified: head/sys/sys/elf_common.h == --- head/sys/sys/elf_common.h Sat Jan 3 13:24:08 2009(r186719) +++ head/sys/sys/elf_common.h Sat Jan 3 13:42:49 2009(r186720) @@ -267,6 +267,7 @@ typedef struct { #defineSHT_SUNW_dof0x6ff4 #defineSHT_SUNW_cap0x6ff5 #defineSHT_SUNW_SIGNATURE 0x6ff6 +#defineSHT_GNU_HASH0x6ff6 #defineSHT_SUNW_ANNOTATE 0x6ff7 #defineSHT_SUNW_DEBUGSTR 0x6ff8 #defineSHT_SUNW_DEBUG 0x6ff9 ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r186316 - head/sys/sys
Author: kaiw Date: Fri Dec 19 09:32:31 2008 New Revision: 186316 URL: http://svn.freebsd.org/changeset/base/186316 Log: Update elf_common.h with new EM_ types found in the latest ELF gABI. This commit is slightly different from the original patch in the PR: 1. EM_ALPHA keeps the old value for compatibility reason. 2. Non-standard SHT_NUM is not added. 3. Style. PR: kern/118540 Submitted by: Pedro F. Giffuni giffunip[at]tutopia.com Modified: head/sys/sys/elf_common.h Modified: head/sys/sys/elf_common.h == --- head/sys/sys/elf_common.h Fri Dec 19 06:50:15 2008(r186315) +++ head/sys/sys/elf_common.h Fri Dec 19 09:32:31 2008(r186316) @@ -101,6 +101,7 @@ typedef struct { #define ELFOSABI_OPENBSD 12 /* OpenBSD */ #define ELFOSABI_OPENVMS 13 /* Open VMS */ #define ELFOSABI_NSK 14 /* HP Non-Stop Kernel */ +#define ELFOSABI_AROS 15 /* Amiga Research OS */ #define ELFOSABI_ARM 97 /* ARM */ #define ELFOSABI_STANDALONE255 /* Standalone (embedded) application */ @@ -169,6 +170,61 @@ typedef struct { #define EM_TINYJ 61 /* Advanced Logic Corp. TinyJ processor. */ #define EM_X86_64 62 /* Advanced Micro Devices x86-64 */ #defineEM_AMD64EM_X86_64 /* Advanced Micro Devices x86-64 (compat) */ +#define EM_PDSP63 /* Sony DSP Processor. */ +#define EM_FX6666 /* Siemens FX66 microcontroller. */ +#define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 + microcontroller. */ +#define EM_ST7 68 /* STmicroelectronics ST7 8-bit + microcontroller. */ +#define EM_68HC16 69 /* Motorola MC68HC16 microcontroller. */ +#define EM_68HC11 70 /* Motorola MC68HC11 microcontroller. */ +#define EM_68HC08 71 /* Motorola MC68HC08 microcontroller. */ +#define EM_68HC05 72 /* Motorola MC68HC05 microcontroller. */ +#define EM_SVX 73 /* Silicon Graphics SVx. */ +#define EM_ST1974 /* STMicroelectronics ST19 8-bit mc. */ +#define EM_VAX 75 /* Digital VAX. */ +#define EM_CRIS76 /* Axis Communications 32-bit embedded + processor. */ +#define EM_JAVELIN 77 /* Infineon Technologies 32-bit embedded + processor. */ +#define EM_FIREPATH78 /* Element 14 64-bit DSP Processor. */ +#define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor. */ +#define EM_MMIX80 /* Donald Knuth's educational 64-bit proc. */ +#define EM_HUANY 81 /* Harvard University machine-independent + object files. */ +#define EM_PRISM 82 /* SiTera Prism. */ +#define EM_AVR 83 /* Atmel AVR 8-bit microcontroller. */ +#define EM_FR3084 /* Fujitsu FR30. */ +#define EM_D10V85 /* Mitsubishi D10V. */ +#define EM_D30V86 /* Mitsubishi D30V. */ +#define EM_V85087 /* NEC v850. */ +#define EM_M32R88 /* Mitsubishi M32R. */ +#define EM_MN10300 89 /* Matsushita MN10300. */ +#define EM_MN10200 90 /* Matsushita MN10200. */ +#define EM_PJ 91 /* picoJava. */ +#define EM_OPENRISC92 /* OpenRISC 32-bit embedded processor. */ +#define EM_ARC_A5 93 /* ARC Cores Tangent-A5. */ +#define EM_XTENSA 94 /* Tensilica Xtensa Architecture. */ +#define EM_VIDEOCORE 95 /* Alphamosaic VideoCore processor. */ +#define EM_TMM_GPP 96 /* Thompson Multimedia General Purpose + Processor. */ +#define EM_NS32K 97 /* National Semiconductor 32000 series. */ +#define EM_TPC 98 /* Tenor Network TPC processor. */ +#define EM_SNP1K 99 /* Trebia SNP 1000 processor. */ +#define EM_ST200 100 /* STMicroelectronics ST200 microcontroller. */ +#define EM_IP2K101 /* Ubicom IP2xxx microcontroller family. */ +#define EM_MAX 102 /* MAX Processor. */ +#define EM_CR 103 /* National Semiconductor CompactRISC + microprocessor. */ +#define EM_F2MC16 104 /* Fujitsu F2MC16. */ +#define EM_MSP430 105 /* Texas Instruments embedded microcontroller + msp430. */ +#define EM_BLACKFIN106 /* Analog Devices Blackfin (DSP) processor. */ +#define EM_SE_C33 107 /* S1C33 Family of Seiko Epson processors. */ +#define EM_SEP 108 /* Sharp embedded microprocessor. */ +#define EM_ARCA109 /* Arca RISC Microprocessor. */ +#define EM_UNICORE 110 /*