summaryrefslogtreecommitdiffstats
path: root/extras
AgeCommit message (Collapse)AuthorFilesLines
2020-03-06misc: Fix vpp-selinux-policy dependency on CentOS 8Renato Botelho do Couto1-1/+6
policycoreutils-python is now called python3-policycoreutils on CentOS 8. Type: fix Signed-off-by: Renato Botelho do Couto <renato@netgate.com> Change-Id: I46264c66a2a719d546e0926f3bd716e986461963
2020-02-26lldp: API cleanupJakub Grajciar2-10/+8
Use consistent API types. Type: fix Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com> Change-Id: I2fe6b56dc0f224f438ed5f14c0f276d94afbaea8 Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com>
2020-02-26span: API cleanupJakub Grajciar1-9/+5
Use consistent API types. Type: fix Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com> Change-Id: Ifddac07b15b116574de3a97f7c80d7bf6a3171f7 Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com>
2020-02-05stats: fix state counter removalVladimir Isaev2-13/+9
Avoid using vec_del1() for directory vector to keep indexes valid all the time. There are state counters for each slave in LACP bond mode which can be dynamically created and removed. Vector index is used to access these counters. But also vec_del1() is used to remove counter from vector. This function changes the index of the last element, so after this we are unable to access ex-last element using old index. As a result it is not possible to add-del-add two interfaces to the LACP bond: DBGvpp# create bond mode lacp BondEthernet0 DBGvpp# create packet-generator interface pg1 DBGvpp# create packet-generator interface pg2 DBGvpp# bond add BondEthernet0 pg1 DBGvpp# bond add BondEthernet0 pg2 DBGvpp# bond del pg1 DBGvpp# bond del pg2 DBGvpp# bond add BondEthernet0 pg1 DBGvpp# bond add BondEthernet0 pg2 bond add: /if/lacp/1/3/partner-state is already register Type: fix Signed-off-by: Vladimir Isaev <visaev@netgate.com> Change-Id: I2c86e13905eefdef6233369cd4ab5c1b53d123bd
2020-02-05misc: add new type for commit messageMohsin Kazmi1-1/+1
Type: style Change-Id: Ibfa8bd1c0987fd2a5050be6c454f665666eb0210 Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
2020-01-30misc: deprecate dpdk hqosDamjan Marion6-0/+3523
Not in functional state for a long time ... Type: refactor Change-Id: I2cc1525a6d49518cbc94faf6afbf0d2d0d515f56 Signed-off-by: Damjan Marion <damarion@cisco.com>
2020-01-30misc: deprecate netmap and ixge driversDamjan Marion13-0/+6398
Both are out of sync for long time... Type: refactor Change-Id: I7de3170d35330fc172501d87655dfef91998b8fe Signed-off-by: Damjan Marion <damarion@cisco.com>
2020-01-30misc: move configs to extras/configsDamjan Marion8-0/+0
Type: refactor Change-Id: I64665b290e2c42bbd9b0e877e9e4b028090b0ede Signed-off-by: Damjan Marion <damarion@cisco.com>
2020-01-27classify: pcap / packet trace debug CLI bugsDave Barach1-1/+3
"classify filter trace ... " and "classify filter pcap ..." are mutually exclusive. vnet_pcap_dispatch_trace_configure needs to check for set->table_indices == NULL. Type: fix Ticket: VPP-1827 Signed-off-by: Dave Barach <dave@barachs.net> Change-Id: I43733364087ffb0a43de92e450955033431d559d
2020-01-27libmemif: memif_control_fd_update always pass context from libmemif_mainJakub Grajciar3-17/+23
Event polling instance is always identified by libmemif main private context. Fixes event polling handled by libmemif. Type: fix Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com> Change-Id: I51dcdb279b18f8ce97bad3b2695848e0b25a232d
2020-01-03build: Fix Subject-line feature list extractionJon Loeliger1-1/+2
Bang on sed until a better incantation appears. Change-Id: Ib8ad0996b6325db0fe983c86dd7dc553c9d388c4 Type: fix Fixes: 26ce6ca1fe6f524a9049444fe8d55042fd7530a6 Signed-off-by: Jon Loeliger <jdl@netgate.com>
2019-12-19bash: add -j <jobs> option to vpp-make-testDave Wallace1-7/+18
- Also cleanup local var declarations - remove extraneous export statement Type: test Change-Id: I22198a65d1785ba53d1de22b2aa498cab910701b Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
2019-12-17misc: Add CentOS 8 package supportRenato Botelho do Couto1-4/+10
Type: feature Added missing dependencies on RPM spec file and install-dep Ticket: VPP-1800 Signed-off-by: Renato Botelho do Couto <renato@netgate.com> Change-Id: I91d39c94b3f03c213249dff42b264718ef772bdb
2019-12-17build: export vapi generation in vpp-devOliver Giles1-0/+3
Adds the higher-level vapi generation to cmake/api.cmake and exposes the necessary python scripts in vpp-dev, so that out-of-tree/downstream plugins can also leverage the more convenient API. Type: feature Signed-off-by: Oliver Giles <oliver_g@radwin.com> Change-Id: I8c40a14d27ba3cb972c6907632e03c0e7b0ce982
2019-12-17ip: Protocol Independent IP NeighborsNeale Ranns13-35/+45
Type: feature - ip-neighbour: generic neighbour handling; APIs, DBs, event handling, aging - arp: ARP protocol implementation - ip6-nd; IPv6 neighbor discovery implementation; separate ND, MLD, RA - ip6-link; manage link-local addresses - l2-arp-term; events separated from IP neighbours, since they are not the same. vnet retains just enough education to perform ND/ARP packet construction. arp and ip6-nd to be moved to plugins soon. Change-Id: I88dedd0006b299344f4c7024a0aa5baa6b9a8bbe Signed-off-by: Neale Ranns <nranns@cisco.com>
2019-12-11devices: tap API cleanupJakub Grajciar2-19/+18
Use consistent API types. Type: fix Change-Id: I11cc7f6347b7a60e5fd41e54f0c7994e2d81199f Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com>
2019-12-05classify: vpp packet tracer supportDave Barach1-0/+20
Configure n-tuple classifier filters which apply to the vpp packet tracer. Update the documentation to reflect the new feature. Add a test vector. Type: feature Signed-off-by: Dave Barach <dave@barachs.net> Change-Id: Iefa911716c670fc12e4825b937b62044433fec36
2019-12-04vom: get interface type from vpp device typeMohsin Kazmi2-22/+21
Type: feature Change-Id: Ia626188c22dc80c2b7a06b61cf0af435ee53d1e7 Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
2019-11-20bash: vpp-make-test bash functionDave Wallace1-0/+140
- A bash function which enhances reproduction, debugging, and verification of intermittent make test failures. Type: test Change-Id: I2faf56829d0633963506e136a68b77b8a1b32236 Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
2019-11-15build: make checkstyle-* targets and cleanupDave Wallace1-0/+3
- Add new make targets: checkstyle-commit checkstyle-test (alias test-checkstyle) checkstyle-all test-wipe-papi (papi-wipe deprecated) retest-all retest-all-debug install-deps (alias install-dep) install-ext-dep (alias install-ext-deps) - Fix .PHONY dependencies - Cleanup redundant target commands Type: refactor Change-Id: I08b0ef459d421a09fb929aee5cd6baec329931b7 Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
2019-11-06misc: add lcov scripts, README.mdDave Barach3-0/+62
See extras/lcov Type: feature Signed-off-by: Dave Barach <dave@barachs.net> Change-Id: Id229436bd94cd18bcd0f3a3d938eae2b28d5b1f5
2019-11-05misc: Fix python scripts shebang lineRenato Botelho do Couto2-2/+2
Type: fix Since CentOS 8, RPM build script doesn't accept '#!/usr/bin/env python' as a valid shebang line. It requires scripts to explicitly chose between python2 or python3. Change all to use python3 as suggested by Paul Vinciguerra. Depends-On: https://gerrit.fd.io/r/23170 Signed-off-by: Renato Botelho do Couto <renato@netgate.com> Change-Id: Ie72af9f60fd0609e07f05b70f8d96e738b2754d1
2019-11-05libmemif: reset number of queues on disconnectJakub Grajciar1-9/+6
Type: fix Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com> Change-Id: If4df47b1109ac90d4d5834b3aa7d326f6b3761d2
2019-10-30vpp_config: fix typos in templatesPaul Vinciguerra2-3/+3
Type: style Change-Id: Ia435604c8c48a78054848095567f1e54d028227e Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2019-10-10http_static: add .json contentDave Barach1-0/+2
Type: feature Signed-off-by: Dave Barach <dave@barachs.net> Change-Id: Ibf8583175c181dc12a589b3e6c11a10ee77fc160
2019-10-09docs: Add macos build documentationNathan Skrzypczak2-0/+91
Type: docs Change-Id: Iee03aacab2cfcb4e87190302dc641e8273b7f096 Signed-off-by: Nathan Skrzypczak <nathan.skrzypczak@gmail.com>
2019-10-03emacs: track improvements in vppapigenDave Barach7-270/+17
Remove boilerplate which is now generated by vppapigen Type: refactor Signed-off-by: Dave Barach <dave@barachs.net> Change-Id: I36bff1a651ac48caa969ed76d963b0a733ef5532
2019-10-03dhcp: API cleanupJakub Grajciar2-6/+8
Use consistent API types. Type: fix Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com> Change-Id: Ia63d920788add2584060a240321acced7a471640
2019-09-18builtinurl: initial working attemptDave Barach2-1/+84
Note that the builtin URLs are disabled by default. To activate, "builtinurl enable" or use the builtinurl_enable API. See .../extras/http/sample.md for some Hugo-friendly .md w/ embedded Javascript that accesses the builtin URLs. Type: feature Signed-off-by: Dave Barach <dave@barachs.net> Change-Id: I6d82d9292c41d6d2d90be73ba8a1a043fb20c986
2019-09-11bonding: API cleanupJakub Grajciar1-2/+2
Use consistent API types. Type: fix Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com> Change-Id: Idbba4ab6a412b75338e3149e51476693f0862f16 Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com>
2019-09-10misc: clean up "pcap [rx|tx] trace" debug CLIDave Barach1-0/+34
Separate debug CLI arg parsing from the underlying action function. Fixes a number of subtle ordering dependencies, and will allow us to add a binary API to control the feature at some point in the future. Type: refactor Ticket: VPP-1770 Signed-off-by: Dave Barach <dave@barachs.net> Change-Id: Id0dbeda06dad20e756c941c691e2088ce3c50ec7
2019-09-09libmemif: prevent crash in case of invalid connection handleJakub Grajciar1-9/+31
Type: fix Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com> Change-Id: I803c86a48e0148ef143026a5cd93e4510c4f0611 Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com>
2019-09-07ip: fix udp/tcp checksum corner casesDave Barach1-0/+276
When checksumming chained buffers with odd lengths: insert a NULL byte, or the calculation fails. Type: fix Signed-off-by: Dave Barach <dave@barachs.net> Signed-off-by: John Lo <loj@cisco.com> Change-Id: I380f7c42897bdb28c8c29aa1c4cdaaa849cc9ecc
2019-09-03api: enforce vla is last and fixed string typeOle Troan3-7/+7
Enforce that variable length fields are the last element of API messages. Add a 'fixed' version of string type, since dealing with multiple variable length strings turned out too painful for the C language bindings. The string type is now: { string name[64]; // NUL terminated C-string. Essentially decays to u8 name[64] string name[]; // Variable length string with embedded len field (vl_api_string_t) }; The latter notation could be made available to other types as well. e.g. { vl_api_address_t addresses[]; } instead of { u32 n_addr; vl_api_address_t addresses[n_addr]; }; Type: fix Change-Id: I18fa17ef47227633752ab50453e8d20a652a9f9b Signed-off-by: Ole Troan <ot@cisco.com>
2019-08-21libmemif: introduce 'memif_per_thread_' namespaceJakub Grajciar9-113/+1314
APIs in 'memif_per_thread_' namespace are used to split the global database into separate databases, to improve multi-thread use cases. Using 'memif_per_thread_init' client can create separate libmemif databases (libmemif_main_t). Client will reference these databases using memif_per_thread_handle_t. Each database requires unique socket. Created interface will be stored in the same database as the socket passed in connection arguments. Example code: extras/libmemif/examples/icmp_responder_3-1/main.c Type: feature Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com> Change-Id: I261563ecc34761a76e94f20c20015394398ddfd7 Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com>
2019-08-20api: Cleanup APIs interface.apiJakub Grajciar4-15/+19
Use of consistent API types for interface.api Type: fix Change-Id: I88206d7d0907cffd564031f73c9a996df2e5e21a Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com>
2019-08-12papi: Revert vpp-api-python to py2, add py3 pkgIan Wells1-2/+29
A previous commit, ca3d38ae18c21ce37212f0d5d5f4a1702429e70c, converts the vpp-api-python package from a python2 library to a python3 one. This changes the behaviour of the package and breaks anything that uses it as a dependency. This change reverts the package behaviour to a python2 package, and additionally adds a *separate* python3 package for correct python3 behaviour. Type: fix Fixes: VPP-1738 Signed-Off-By: Ian Wells <iawells@cisco.com> Change-Id: I54eb45156eb6e00fc4cd5b48e7a0aa17fd2f43f7 Signed-off-by: Dave Barach <dave@barachs.net>
2019-08-10http_static: tls supportDave Barach2-0/+13
Type: refactor Signed-off-by: Dave Barach <dave@barachs.net> Change-Id: I45745e568cd943293d0015a61f67ec799b6804d8
2019-08-07vom: export/install cmake filesNeale Ranns6-1/+169
Type: feature allow other projects to use cmake modules to find VOM Change-Id: I00e01e9bec3ecf79903cd522d2770bdb70e5399b Signed-off-by: Neale Ranns <nranns@cisco.com>
2019-07-31qos: Store functionNeale Ranns7-1/+653
Type: feature store: write a QoS value into the buffer meta-data record: Extract a QoS value from a packet header and store it. mark: Make a change to the content of a packet header by writing a stored QoS value Change-Id: I07d1e87dd1ca90d40ac1ae1774fee1b272cab83f Signed-off-by: Neale Ranns <nranns@cisco.com>
2019-07-26libmemif: fix autoconnectJakub Grajciar1-4/+4
Type: fix Change-Id: I426e210c47869904a01712b765db2356439f706f Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com>
2019-07-26dhcp ip: DSCP settings for transmitted DHCP packetsNeale Ranns8-17/+174
Type: feature - Define the ip_dscp_t and use in the IP headers - Add DSCP setting to the DHCP client for use with packet TX Change-Id: If220dde0017ea78793747d65f53e11daf23a28fa Signed-off-by: Neale Ranns <nranns@cisco.com>
2019-07-25vom: QoS supportNeale Ranns17-0/+2132
Type: feature Change-Id: If517d10c318fc17fdbd797fac8d974d9851f6442 Signed-off-by: Neale Ranns <nranns@cisco.com>
2019-07-25libmemif: fix chained buffer flagJakub Grajciar1-0/+1
fixes issue: MEMIF_DESC_FLAG_NEXT persisted when enqueueing stored buffers Type: fix Change-Id: I9e973ed6e0339612fe1dd3e3bd80ed7c05093791 Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com>
2019-07-12docs: how to enable coredump with systemdBenoît Ganne1-0/+5
Type: docs Change-Id: I1f657389fec716cc6cdc942803e65f861ffea5f5 Signed-off-by: Benoît Ganne <bganne@cisco.com>
2019-07-11vom: Fix reference to flags in GBP bridge-domainNeale Ranns1-1/+1
Type: fix Fixes: 5e82b050 Change-Id: I8f709c5303861ea9984144ce5543c86c934869bb Signed-off-by: Neale Ranns <nranns@cisco.com>
2019-07-10emacs: update the vat plugin generatorDave Barach1-17/+1
Use the VAT_PLUGIN_REGISTER macro. Type: refactor Change-Id: I5ab9f311028c07a37a40cc1328d9724f852783ee Signed-off-by: Dave Barach <dave@barachs.net>
2019-07-09misc: extras update list_api_changes.py to PY3Paul Vinciguerra1-11/+14
Type: refactor Change-Id: I099d78393675b7aac37e89df98527c361054077b Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2019-07-05misc: allow second ':' in commit messageDamjan Marion1-1/+1
Type: fix Fixes: 26ce6ca Change-Id: I3ffa1e60966ba3e20670a7b95bba53e86e9861e0 Signed-off-by: Damjan Marion <damarion@cisco.com>
2019-07-03fib: allow route delete with no paths and multipath=0 to remove theNeale Ranns1-1/+2
whole route Type: fix Fixes: 097fa66b Change-Id: I017ab5797670eb278c27c6e306cd8cadaacddf9d Signed-off-by: Neale Ranns <nranns@cisco.com>
an> /* Legal values for architecture. */ #define foreach_elf_architecture \ _ (NONE, 0) /* No machine */ \ _ (M32, 1) /* AT&T WE 32100 */ \ _ (SPARC, 2) /* SUN SPARC */ \ _ (386, 3) /* Intel 80386 */ \ _ (68K, 4) /* Motorola m68k family */ \ _ (88K, 5) /* Motorola m88k family */ \ _ (860, 7) /* Intel 80860 */ \ _ (MIPS, 8) /* MIPS R3000 big-endian */ \ _ (S370, 9) /* IBM System/370 */ \ _ (MIPS_RS3_LE, 10) /* MIPS R3000 little-endian */ \ _ (PARISC, 15) /* HPPA */ \ _ (VPP500, 17) /* Fujitsu VPP500 */ \ _ (SPARC32PLUS, 18) /* Sun's "v8plus" */ \ _ (960, 19) /* Intel 80960 */ \ _ (PPC, 20) /* PowerPC */ \ _ (PPC64, 21) /* PowerPC 64-bit */ \ _ (S390, 22) /* IBM S390 */ \ _ (V800, 36) /* NEC V800 series */ \ _ (FR20, 37) /* Fujitsu FR20 */ \ _ (RH32, 38) /* TRW RH-32 */ \ _ (RCE, 39) /* Motorola RCE */ \ _ (ARM, 40) /* ARM */ \ _ (FAKE_ALPHA, 41) /* Digital Alpha */ \ _ (SH, 42) /* Hitachi SH */ \ _ (SPARCV9, 43) /* SPARC v9 64-bit */ \ _ (TRICORE, 44) /* Siemens Tricore */ \ _ (ARC, 45) /* Argonaut RISC Core */ \ _ (H8_300, 46) /* Hitachi H8/300 */ \ _ (H8_300H, 47) /* Hitachi H8/300H */ \ _ (H8S, 48) /* Hitachi H8S */ \ _ (H8_500, 49) /* Hitachi H8/500 */ \ _ (IA_64, 50) /* Intel Merced */ \ _ (MIPS_X, 51) /* Stanford MIPS-X */ \ _ (COLDFIRE, 52) /* Motorola Coldfire */ \ _ (68HC12, 53) /* Motorola M68HC12 */ \ _ (MMA, 54) /* Fujitsu MMA Multimedia Accel. */ \ _ (PCP, 55) /* Siemens PCP */ \ _ (NCPU, 56) /* Sony nCPU embeeded RISC */ \ _ (NDR1, 57) /* Denso NDR1 microprocessor */ \ _ (STARCORE, 58) /* Motorola Start*Core processor */ \ _ (ME16, 59) /* Toyota ME16 processor */ \ _ (ST100, 60) /* STMicroelectronic ST100 */ \ _ (TINYJ, 61) /* Advanced Logic Corp. Tinyj */ \ _ (X86_64, 62) /* AMD x86-64 architecture */ \ _ (PDSP, 63) /* Sony DSP Processor */ \ _ (FX66, 66) /* Siemens FX66 microcontroller */ \ _ (ST9PLUS, 67) /* STMicroelectronics ST9+ 8/16 mc */ \ _ (ST7, 68) /* STmicroelectronics ST7 8 bit mc */ \ _ (68HC16, 69) /* Motorola MC68HC16 */ \ _ (68HC11, 70) /* Motorola MC68HC11 */ \ _ (68HC08, 71) /* Motorola MC68HC08 */ \ _ (68HC05, 72) /* Motorola MC68HC05 */ \ _ (SVX, 73) /* Silicon Graphics SVx */ \ _ (ST19, 74) /* STMicroelectronics ST19 8 bit mc */ \ _ (VAX, 75) /* Digital VAX */ \ _ (CRIS, 76) /* Axis 32-bit embedded proc. */ \ _ (JAVELIN, 77) /* Infineon 32-bit embedded proc. */ \ _ (FIREPATH, 78) /* Element 14 64-bit DSP Processor */ \ _ (ZSP, 79) /* LSI Logic 16-bit DSP Processor */ \ _ (MMIX, 80) /* Knuth's 64-bit processor */ \ _ (HUANY, 81) /* Harvard machine-independent */ \ _ (PRISM, 82) /* SiTera Prism */ \ _ (AVR, 83) /* Atmel AVR 8-bit microcontroller */ \ _ (FR30, 84) /* Fujitsu FR30 */ \ _ (D10V, 85) /* Mitsubishi D10V */ \ _ (D30V, 86) /* Mitsubishi D30V */ \ _ (V850, 87) /* NEC v850 */ \ _ (M32R, 88) /* Mitsubishi M32R */ \ _ (MN10300, 89) /* Matsushita MN10300 */ \ _ (MN10200, 90) /* Matsushita MN10200 */ \ _ (PJ, 91) /* picoJava */ \ _ (OPENRISC, 92) /* OpenRISC 32-bit processor */ \ _ (ARC_A5, 93) /* ARC Cores Tangent-A5 */ \ _ (XTENSA, 94) /* Tensilica Xtensa Architecture */ \ _ (ALPHA, 0x9026) #define _(f) ELF_##f, typedef enum { foreach_elf_file_class ELF_N_FILE_CLASS, } elf_file_class_t; typedef enum { foreach_elf_data_encoding ELF_N_DATA_ENCODING, } elf_data_encoding_t; #undef _ #define _(f,i) ELF_##f = i, typedef enum { foreach_elf_abi } elf_abi_t; typedef enum { foreach_elf_file_type } elf_file_type_t; #undef _ typedef enum { #define _(f,i) ELF_ARCH_##f = i, foreach_elf_architecture #undef _ } elf_architecture_t; typedef struct { /* 0x7f ELF */ u8 magic[4]; elf_file_class_t file_class:8; elf_data_encoding_t data_encoding:8; u8 file_version_ident; elf_abi_t abi:8; u8 abi_version; u8 pad[7]; elf_file_type_t file_type:16; elf_architecture_t architecture:16; u32 file_version; } elf_first_header_t; /* 32/64 bit file header following basic file header. */ #define foreach_elf32_file_header \ _ (u32, entry_point) \ _ (u32, segment_header_file_offset) \ _ (u32, section_header_file_offset) \ _ (u32, flags) \ _ (u16, n_bytes_this_header) \ _ (u16, segment_header_size) \ _ (u16, segment_header_count) \ _ (u16, section_header_size) \ _ (u16, section_header_count) \ _ (u16, section_header_string_table_index) #define foreach_elf64_file_header \ _ (u64, entry_point) \ _ (u64, segment_header_file_offset) \ _ (u64, section_header_file_offset) \ _ (u32, flags) \ _ (u16, n_bytes_this_header) \ _ (u16, segment_header_size) \ _ (u16, segment_header_count) \ _ (u16, section_header_size) \ _ (u16, section_header_count) \ _ (u16, section_header_string_table_index) /* Section header. */ #define foreach_elf32_section_header \ _ (u32, name) \ _ (u32, type) \ _ (u32, flags) \ _ (u32, exec_address) \ _ (u32, file_offset) \ _ (u32, file_size) \ _ (u32, link) \ _ (u32, additional_info) \ _ (u32, align) \ _ (u32, entry_size) #define foreach_elf64_section_header \ _ (u32, name) \ _ (u32, type) \ _ (u64, flags) \ _ (u64, exec_address) \ _ (u64, file_offset) \ _ (u64, file_size) \ _ (u32, link) \ _ (u32, additional_info) \ _ (u64, align) \ _ (u64, entry_size) /* Program segment header. */ #define foreach_elf32_segment_header \ _ (u32, type) \ _ (u32, file_offset) \ _ (u32, virtual_address) \ _ (u32, physical_address) \ _ (u32, file_size) \ _ (u32, memory_size) \ _ (u32, flags) \ _ (u32, align) #define foreach_elf64_segment_header \ _ (u32, type) \ _ (u32, flags) \ _ (u64, file_offset) \ _ (u64, virtual_address) \ _ (u64, physical_address) \ _ (u64, file_size) \ _ (u64, memory_size) \ _ (u64, align) /* Symbol table. */ #define foreach_elf32_symbol_header \ _ (u32, name) \ _ (u32, value) \ _ (u32, size) \ /* binding upper 4 bits; type lower 4 bits */ \ _ (u8, binding_and_type) \ _ (u8, visibility) \ _ (u16, section_index) #define foreach_elf64_symbol_header \ _ (u32, name) \ _ (u8, binding_and_type) \ _ (u8, visibility) \ _ (u16, section_index) \ _ (u64, value) \ _ (u64, size) #define _(t,f) t f; typedef struct { foreach_elf32_file_header} elf32_file_header_t; typedef struct { foreach_elf64_file_header} elf64_file_header_t; typedef struct { foreach_elf32_section_header} elf32_section_header_t; typedef struct { foreach_elf64_section_header} elf64_section_header_t; typedef struct { foreach_elf32_segment_header} elf32_segment_header_t; typedef struct { foreach_elf64_segment_header} elf64_segment_header_t; typedef struct { foreach_elf32_symbol_header} elf32_symbol_t; typedef struct { foreach_elf64_symbol_header} elf64_symbol_t; #undef _ /* Special section names. */ #define foreach_elf_symbol_reserved_section_index \ _ (ABSOLUTE, 0xfff1) /* Associated symbol is absolute */ \ _ (COMMON, 0xfff2) /* Associated symbol is common */ \ _ (XINDEX, 0xffff) /* Index is in extra table. */ #define ELF_SYMBOL_SECTION_RESERVED_LO 0xff00 #define ELF_SYMBOL_SECTION_RESERVED_HI 0xffff #define ELF_SYMBOL_SECTION_ARCH_SPECIFIC_LO 0xff00 #define ELF_SYMBOL_SECTION_ARCH_SPECIFIC_HI 0xff1f #define ELF_SYMBOL_SECTION_OS_SPECIFIC_LO 0xff20 #define ELF_SYMBOL_SECTION_OS_SPECIFIC_HI 0xff3f /* Section types. */ #define foreach_elf_section_type \ _ (UNUSED, 0) \ _ (PROGRAM_DATA, 1) \ _ (SYMBOL_TABLE, 2) \ _ (STRING_TABLE, 3) \ _ (RELOCATION_ADD, 4) \ _ (SYMBOL_TABLE_HASH, 5) \ _ (DYNAMIC, 6) /* Dynamic linking information */ \ _ (NOTE, 7) /* Notes */ \ _ (NO_BITS, 8) /* Program space with no data (bss) */ \ _ (RELOCATION, 9) /* Relocation entries, no addends */ \ _ (DYNAMIC_SYMBOL_TABLE, 11) /* Dynamic linker symbol table */ \ _ (INIT_ARRAY, 14) /* Array of constructors */ \ _ (FINI_ARRAY, 15) /* Array of destructors */ \ _ (PREINIT_ARRAY, 16) /* Array of pre-constructors */ \ _ (GROUP, 17) /* Section group */ \ _ (SYMTAB_SHNDX, 18) /* Extended section indices */ \ _ (OS_SPECIFIC_LO, 0x60000000) /* Start OS-specific */ \ _ (GNU_LIBLIST, 0x6ffffff7) /* Prelink library list */ \ _ (CHECKSUM, 0x6ffffff8) /* Checksum for DSO content. */ \ _ (SUNW_MOVE, 0x6ffffffa) \ _ (SUNW_COMDAT, 0x6ffffffb) \ _ (SUNW_SYMINFO, 0x6ffffffc) \ _ (GNU_VERDEF, 0x6ffffffd) /* Version definition section. */ \ _ (GNU_VERNEED, 0x6ffffffe) /* Version needs section. */ \ _ (GNU_VERSYM, 0x6fffffff) /* Version symbol table. */ \ _ (ARCH_SPECIFIC_LO, 0x70000000) /* Start of processor-specific */ \ _ (ARCH_SPECIFIC_HI, 0x7fffffff) /* End of processor-specific */ \ _ (APP_SPECIFIC_LO, 0x80000000) /* Start of application-specific */ \ _ (APP_SPECIFIC_HI, 0x8fffffff) /* End of application-specific */ /* Section flags. */ #define foreach_elf_section_flag \ _ (WRITE, 0) \ _ (ALLOC, 1) \ _ (EXEC, 2) \ _ (MERGE, 3) \ _ (STRING_TABLE, 5) \ _ (INFO_LINK, 6) \ _ (PRESERVE_LINK_ORDER, 7) \ _ (OS_NON_CONFORMING, 8) \ _ (GROUP, 9) \ _ (TLS, 10) \ _ (OS_SPECIFIC_LO, 20) \ _ (OS_SPECIFIC_HI, 27) \ _ (ARCH_SPECIFIC_LO, 28) \ _ (ARCH_SPECIFIC_HI, 31) typedef enum { #define _(f,i) ELF_SECTION_##f = i, foreach_elf_section_type #undef _ ELF_SECTION_OS_SPECIFIC_HI = 0x6fffffff, } elf_section_type_t; typedef enum { #define _(f,i) ELF_SECTION_FLAG_BIT_##f = i, foreach_elf_section_flag #undef _ } elf_section_flag_bit_t; typedef enum { #define _(f,i) ELF_SECTION_FLAG_##f = 1 << ELF_SECTION_FLAG_BIT_##f, foreach_elf_section_flag #undef _ } elf_section_flag_t; /* Symbol bindings (upper 4 bits of binding_and_type). */ #define foreach_elf_symbol_binding \ _ (LOCAL, 0) /* Local symbol */ \ _ (GLOBAL, 1) /* Global symbol */ \ _ (WEAK, 2) /* Weak symbol */ \ _ (OS_SPECIFIC_LO, 10) /* Start of OS-specific */ \ _ (OS_SPECIFIC_HI, 12) /* End of OS-specific */ \ _ (ARCH_SPECIFIC_LO, 13) /* Start of processor-specific */ \ _ (ARCH_SPECIFIC_HI, 15) /* End of processor-specific */ /* Symbol types (lower 4 bits of binding_and_type). */ #define foreach_elf_symbol_type \ _ (NONE, 0) \ _ (DATA, 1) /* Symbol is a data object */ \ _ (CODE, 2) /* Symbol is a code object */ \ _ (SECTION, 3) /* Symbol associated with a section */ \ _ (FILE, 4) /* Symbol's name is file name */ \ _ (COMMON, 5) /* Symbol is a common data object */ \ _ (TLS, 6) /* Symbol is thread-local data */ \ _ (OS_SPECIFIC_LO, 10) /* Start of OS-specific */ \ _ (OS_SPECIFIC_HI, 12) /* End of OS-specific */ \ _ (ARCH_SPECIFIC_LO, 13) /* Start of processor-specific */ \ _ (ARCH_SPECIFIC_HI, 15) /* End of processor-specific */ /* Symbol visibility. */ #define foreach_elf_symbol_visibility \ _ (DEFAULT, 0) /* Default symbol visibility rules */ \ _ (INTERNAL, 1) /* Processor specific hidden class */ \ _ (HIDDEN, 2) /* Unavailable in other modules */ \ _ (PROTECTED, 3) /* Not preemptible, not exported */ /* The syminfo section if available contains additional information about every dynamic symbol. */ typedef struct { u16 bound_to; u16 flags; } elf_symbol_info_t; /* Possible values for bound_to. */ #define foreach_elf_symbol_info_bound_to \ _ (SELF, 0xffff) /* Symbol bound to self */ \ _ (PARENT, 0xfffe) /* Symbol bound to parent */ \ _ (RESERVED_LO, 0xff00) \ _ (RESERVED_HI, 0xffff) /* Symbol info flags. */ #define foreach_elf_symbol_info_flags \ _ (DIRECT) /* Direct bound symbol */ \ _ (PASS_THRU) /* Pass-thru symbol for translator */ \ _ (COPY) /* Symbol is a copy-reloc */ \ _ (LAZY_LOAD) /* Symbol bound to object to be lazy loaded */ /* Relocation table entry with/without addend. */ typedef struct { u32 address; u32 symbol_and_type; /* high 24 symbol, low 8 type. */ i32 addend[0]; } elf32_relocation_t; typedef struct { u64 address; u64 symbol_and_type; /* high 32 symbol, low 32 type. */ i64 addend[0]; } elf64_relocation_t; typedef struct { u64 address; u64 symbol_and_type; u64 addend; } elf_relocation_with_addend_t; #define elf_relocation_next(r,type) \ ((void *) ((r) + 1) \ + ((type) == ELF_SECTION_RELOCATION_ADD ? sizeof ((r)->addend[0]) : 0)) /* Segment type. */ #define foreach_elf_segment_type \ _ (UNUSED, 0) \ _ (LOAD, 1) /* Loadable program segment */ \ _ (DYNAMIC, 2) /* Dynamic linking information */ \ _ (INTERP, 3) /* Program interpreter */ \ _ (NOTE, 4) /* Auxiliary information */ \ _ (SEGMENT_TABLE, 6) /* Entry for header table itself */ \ _ (TLS, 7) /* Thread-local storage segment */ \ _ (OS_SPECIFIC_LO, 0x60000000) /* Start of OS-specific */ \ _ (GNU_EH_FRAME, 0x6474e550) /* GCC .eh_frame_hdr segment */ \ _ (GNU_STACK, 0x6474e551) /* Indicates stack executability */ \ _ (GNU_RELRO, 0x6474e552) /* Read-only after relocation */ \ _ (SUNW_BSS, 0x6ffffffa) /* Sun specific BSS */ \ _ (SUNW_STACK, 0x6ffffffb) /* Sun specific stack */ \ _ (OS_SPECIFIC_HI, 0x6fffffff) /* End of OS-specific */ \ _ (ARCH_SPECIFIC_LO, 0x70000000) /* Start of processor-specific */ \ _ (ARCH_SPECIFIC_HI, 0x7fffffff) /* End of processor-specific */ /* Segment flags. */ #define foreach_elf_segment_flag \ _ (EXEC, 0) \ _ (WRITE, 1) \ _ (READ, 2) \ _ (OS_SPECIFIC_LO, 20) \ _ (OS_SPECIFIC_HI, 27) \ _ (ARCH_SPECIFIC_LO, 28) \ _ (ARCH_SPECIFIC_HI, 31) typedef enum { #define _(f,i) ELF_SEGMENT_##f = i, foreach_elf_segment_type #undef _ } elf_segment_type_t; typedef enum { #define _(f,i) ELF_SEGMENT_FLAG_BIT_##f = i, foreach_elf_segment_flag #undef _ } elf_segment_flag_bit_t; typedef enum { #define _(f,i) ELF_SEGMENT_FLAG_##f = 1 << ELF_SEGMENT_FLAG_BIT_##f, foreach_elf_segment_flag #undef _ } elf_segment_flag_t; #define foreach_elf32_dynamic_entry_header \ _ (u32, type) \ _ (u32, data) #define foreach_elf64_dynamic_entry_header \ _ (u64, type) \ _ (u64, data) #define _(t,f) t f; typedef struct { foreach_elf32_dynamic_entry_header} elf32_dynamic_entry_t; typedef struct { foreach_elf64_dynamic_entry_header} elf64_dynamic_entry_t; #undef _ #define foreach_elf_dynamic_entry_type \ _ (END, 0) /* Marks end of dynamic section */ \ _ (NEEDED_LIBRARY, 1) /* Name of needed library */ \ _ (PLT_RELOCATION_SIZE, 2) /* Size in bytes of PLT relocs */ \ _ (PLT_GOT, 3) /* Processor defined value */ \ _ (SYMBOL_HASH, 4) /* Address of symbol hash table */ \ _ (STRING_TABLE, 5) /* Address of string table */ \ _ (SYMBOL_TABLE, 6) /* Address of symbol table */ \ _ (RELA_ADDRESS, 7) /* Address of Rela relocs */ \ _ (RELA_SIZE, 8) /* Total size of Rela relocs */ \ _ (RELA_ENTRY_SIZE, 9) /* Size of one Rela reloc */ \ _ (STRING_TABLE_SIZE, 10) /* Size of string table */ \ _ (SYMBOL_TABLE_ENTRY_SIZE, 11) /* Size of one symbol table entry */ \ _ (INIT_FUNCTION, 12) /* Address of init function */ \ _ (FINI_FUNCTION, 13) /* Address of termination function */ \ _ (SONAME, 14) /* Name of shared object */ \ _ (RPATH, 15) /* Library search path (deprecated) */ \ _ (SYMBOLIC, 16) /* Start symbol search here */ \ _ (REL, 17) /* Address of Rel relocs */ \ _ (RELSZ, 18) /* Total size of Rel relocs */ \ _ (RELENT, 19) /* Size of one Rel reloc */ \ _ (PLT_RELOCATION_TYPE, 20) /* Type of reloc in PLT */ \ _ (DEBUG, 21) /* For debugging; unspecified */ \ _ (TEXTREL, 22) /* Reloc might modify .text */ \ _ (PLT_RELOCATION_ADDRESS, 23) /* Address of PLT relocs */ \ _ (BIND_NOW, 24) /* Process relocations of object */ \ _ (INIT_ARRAY, 25) /* Array with addresses of init fct */ \ _ (FINI_ARRAY, 26) /* Array with addresses of fini fct */ \ _ (INIT_ARRAYSZ, 27) /* Size in bytes of DT_INIT_ARRAY */ \ _ (FINI_ARRAYSZ, 28) /* Size in bytes of DT_FINI_ARRAY */ \ _ (RUN_PATH, 29) /* Library search path */ \ _ (FLAGS, 30) /* Flags for object being loaded */ \ _ (ENCODING, 31) /* Start of encoded range */ \ _ (PREINIT_ARRAY, 32) /* Array with addresses of fns */ \ _ (PREINIT_ARRAY_SIZE, 33) /* Size of PREINIT_ARRAY in bytes. */ \ _ (GNU_PRELINKED, 0x6ffffdf5) /* Prelinking timestamp */ \ _ (GNU_CONFLICTSZ, 0x6ffffdf6) /* Size of conflict section */ \ _ (GNU_LIBLISTSZ, 0x6ffffdf7) /* Size of library list */ \ _ (CHECKSUM, 0x6ffffdf8) \ _ (PLTPADSZ, 0x6ffffdf9) \ _ (MOVEENT, 0x6ffffdfa) \ _ (MOVESZ, 0x6ffffdfb) \ _ (FEATURE_1, 0x6ffffdfc) /* Feature selection (DTF_*). */ \ _ (POSFLAG_1, 0x6ffffdfd) /* Flags for following entries. */ \ _ (SYMINSZ, 0x6ffffdfe) /* Size of syminfo table (in bytes) */ \ _ (SYMINENT, 0x6ffffdff) /* Entry size of syminfo */ \ _ (GNU_HASH, 0x6ffffef5) \ _ (GNU_CONFLICT, 0x6ffffef8) /* Start of conflict section */ \ _ (GNU_LIBLIST, 0x6ffffef9) /* Library list */ \ _ (CONFIG, 0x6ffffefa) /* Configuration information. */ \ _ (DEPAUDIT, 0x6ffffefb) /* Dependency auditing. */ \ _ (AUDIT, 0x6ffffefc) /* Object auditing. */ \ _ (PLTPAD, 0x6ffffefd) /* PLT padding. */ \ _ (MOVETAB, 0x6ffffefe) /* Move table. */ \ _ (SYMINFO, 0x6ffffeff) /* Syminfo table. */ \ _ (VERSYM, 0x6ffffff0) \ _ (RELACOUNT, 0x6ffffff9) \ _ (RELCOUNT, 0x6ffffffa) \ _ (FLAGS_1, 0x6ffffffb) /* State flags, see DF_1_* below. */ \ _ (VERSION_DEF, 0x6ffffffc) /* Address of version definition table */ \ _ (VERSION_DEF_COUNT, 0x6ffffffd) /* Number of version definitions */ \ _ (VERSION_NEED, 0x6ffffffe) /* Address of table with needed versions */ \ _ (VERSION_NEED_COUNT, 0x6fffffff) /* Number of needed versions */ \ _ (AUXILIARY, 0x7ffffffd) /* Shared object to load before self */ \ _ (FILTER, 0x7fffffff) /* Shared object to get values from */ typedef enum { #define _(f,n) ELF_DYNAMIC_ENTRY_##f = (n), foreach_elf_dynamic_entry_type #undef _ } elf_dynamic_entry_type_t; /* Values of `d_un.d_val' in the DT_FLAGS entry. */ #define ELF_DYNAMIC_FLAGS_ORIGIN (1 << 0) /* Object may use DF_ORIGIN */ #define ELF_DYNAMIC_FLAGS_SYMBOLIC (1 << 1) /* Symbol resolutions starts here */ #define ELF_DYNAMIC_FLAGS_TEXT_RELOCATIONS (1 << 2) /* Object contains text relocations */ #define ELF_DYNAMIC_FLAGS_BIND_NOW (1 << 3) /* No lazy binding for this object */ #define ELF_DYNAMIC_FLAGS_STATIC_TLS (1 << 4) /* Module uses the static TLS model */ /* State flags selectable in the `d_un.d_val' element of the DT_FLAGS_1 entry in the dynamic section. */ #define DF_1_NOW 0x00000001 /* Set RTLD_NOW for this object. */ #define DF_1_GLOBAL 0x00000002 /* Set RTLD_GLOBAL for this object. */ #define DF_1_GROUP 0x00000004 /* Set RTLD_GROUP for this object. */ #define DF_1_NODELETE 0x00000008 /* Set RTLD_NODELETE for this object. */ #define DF_1_LOADFLTR 0x00000010 /* Trigger filtee loading at runtime. */ #define DF_1_INITFIRST 0x00000020 /* Set RTLD_INITFIRST for this object */ #define DF_1_NOOPEN 0x00000040 /* Set RTLD_NOOPEN for this object. */ #define DF_1_ORIGIN 0x00000080 /* $ORIGIN must be handled. */ #define DF_1_DIRECT 0x00000100 /* Direct binding enabled. */ #define DF_1_TRANS 0x00000200 #define DF_1_INTERPOSE 0x00000400 /* Object is used to interpose. */ #define DF_1_NODEFLIB 0x00000800 /* Ignore default lib search path. */ #define DF_1_NODUMP 0x00001000 /* Object can't be dldump'ed. */ #define DF_1_CONFALT 0x00002000 /* Configuration alternative created. */ #define DF_1_ENDFILTEE 0x00004000 /* Filtee terminates filters search. */ #define DF_1_DISPRELDNE 0x00008000 /* Disp reloc applied at build time. */ #define DF_1_DISPRELPND 0x00010000 /* Disp reloc applied at run-time. */ /* Flags for the feature selection in DT_FEATURE_1. */ #define DTF_1_PARINIT 0x00000001 #define DTF_1_CONFEXP 0x00000002 /* Flags in the DT_POSFLAG_1 entry effecting only the next DT_* entry. */ #define DF_P1_LAZYLOAD 0x00000001 /* Lazyload following object. */ #define DF_P1_GROUPPERM 0x00000002 /* Symbols from next object are not generally available. */ /* Version definition sections. */ typedef struct { u16 version; u16 flags; u16 index; u16 aux_count; u32 name_hash; u32 aux_byte_offset; u32 byte_offset_next_version_definition; } elf_dynamic_version_definition_t; typedef struct { u32 name; u32 next_offset; /* byte offset of ver def aux next entry */ } elf_dynamic_version_definition_aux_t; /* Version definition flags. */ #define ELF_DYNAMIC_VERSION_FILE (1 << 0) /* Version definition of file itself */ #define ELF_DYNAMIC_VERSION_WEAK (1 << 1) /* Weak version identifier */ /* Version symbol index. */ #define ELF_DYNAMIC_VERSYM_LOCAL 0 /* Symbol is local. */ #define ELF_DYNAMIC_VERSYM_GLOBAL 1 /* Symbol is global. */ #define ELF_DYNAMIC_VERSYM_RESERVED_LO 0xff00 /* Beginning of reserved entries. */ #define ELF_DYNAMIC_VERSYM_ELIMINATE 0xff01 /* Symbol is to be eliminated. */ /* Version dependency section. */ #define foreach_elf_dynamic_version_need_field \ _ (u16, version) \ _ (u16, aux_count) \ _ (u32, file_name_offset) \ _ (u32, first_aux_offset) \ _ (u32, next_offset) #define foreach_elf_dynamic_version_need_aux_field \ _ (u32, hash) \ _ (u16, flags) \ _ (u16, versym_index) \ _ (u32, name) \ _ (u32, next_offset) typedef struct { #define _(t,f) t f; foreach_elf_dynamic_version_need_field #undef _ } elf_dynamic_version_need_t; typedef struct { #define _(t,f) t f; foreach_elf_dynamic_version_need_aux_field #undef _ } elf_dynamic_version_need_aux_t; typedef union { elf_dynamic_version_need_t need; elf_dynamic_version_need_aux_t aux; } elf_dynamic_version_need_union_t; /* Note section contents. Each entry in the note section begins with a header of a fixed form. */ typedef struct { u32 name_size; u32 descriptor_size; u32 type; } elf_note_t; /* Known names of notes. */ /* Solaris entries in the note section have this name. */ #define ELF_NOTE_SOLARIS "SUNW Solaris" /* Note entries for GNU systems have this name. */ #define ELF_NOTE_GNU "GNU" /* Defined types of notes for Solaris. */ /* Value of descriptor (one word) is desired pagesize for the binary. */ #define ELF_NOTE_PAGESIZE_HINT 1 /* Defined note types for GNU systems. */ /* ABI information. The descriptor consists of words: word 0: OS descriptor word 1: major version of the ABI word 2: minor version of the ABI word 3: subminor version of the ABI */ #ifndef ELF_NOTE_ABI #define ELF_NOTE_ABI 1 #endif /* Known OSes. These value can appear in word 0 of an ELF_NOTE_ABI note section entry. */ #define ELF_NOTE_OS_LINUX 0 #define ELF_NOTE_OS_GNU 1 #define ELF_NOTE_OS_SOLARIS2 2 #define ELF_NOTE_OS_FREEBSD 3 /* AMD x86-64 relocations. */ #define foreach_elf_x86_64_relocation_type \ _ (NONE, 0) /* No reloc */ \ _ (DIRECT_64, 1) /* Direct 64 bit */ \ _ (PC_REL_I32, 2) /* PC relative 32 bit signed */ \ _ (GOT_REL_32, 3) /* 32 bit GOT entry */ \ _ (PLT_REL_32, 4) /* 32 bit PLT address */ \ _ (COPY, 5) /* Copy symbol at runtime */ \ _ (CREATE_GOT, 6) /* Create GOT entry */ \ _ (CREATE_PLT, 7) /* Create PLT entry */ \ _ (RELATIVE, 8) /* Adjust by program base */ \ _ (PC_REL_I32_GOT, 9) /* 32 bit PC relative offset to GOT */ \ _ (DIRECT_U32, 10) /* Direct 32 bit zero extended */ \ _ (DIRECT_I32, 11) /* Direct 32 bit sign extended */ \ _ (DIRECT_U16, 12) /* Direct 16 bit zero extended */ \ _ (PC_REL_I16, 13) /* 16 bit sign extended pc relative */ \ _ (DIRECT_I8, 14) /* Direct 8 bit sign extended */ \ _ (PC_REL_I8, 15) /* 8 bit sign extended pc relative */ \ _ (DTPMOD64, 16) /* ID of module containing symbol */ \ _ (DTPOFF64, 17) /* Offset in module's TLS block */ \ _ (TPOFF64, 18) /* Offset in initial TLS block */ \ _ (TLSGD, 19) /* 32 bit signed PC relative offset to two GOT entries for GD symbol */ \ _ (TLSLD, 20) /* 32 bit signed PC relative offset to two GOT entries for LD symbol */ \ _ (DTPOFF32, 21) /* Offset in TLS block */ \ _ (GOTTPOFF, 22) /* 32 bit signed PC relative offset to GOT entry for IE symbol */ \ _ (TPOFF32, 23) /* Offset in initial TLS, block) */ typedef struct { elf64_symbol_t *symbols; u32 section_index; u8 *string_table; uword *symbol_by_name; } elf_symbol_table_t; always_inline void elf_symbol_table_free (elf_symbol_table_t * s) { vec_free (s->symbols); hash_free (s->symbol_by_name); } always_inline u8 * elf_symbol_name (elf_symbol_table_t * t, elf64_symbol_t * sym) { return vec_elt_at_index (t->string_table, sym->name); } typedef struct { elf_relocation_with_addend_t *relocations; u32 section_index; } elf_relocation_table_t; always_inline void elf_relocation_table_free (elf_relocation_table_t * r) { vec_free (r->relocations); } typedef struct { elf64_section_header_t header; u32 index; /* Index of segments containing this section. */ uword *segment_index_bitmap; /* Aligned size (included padding not included in header.file_size). */ u64 align_size; i64 exec_address_change; u8 *contents; } elf_section_t; typedef struct { elf64_segment_header_t header; /* Sections contained in this segment. */ uword *section_index_bitmap; u32 index; u8 *contents; } elf_segment_t; typedef struct { u8 need_byte_swap; u8 parsed_symbols; char *file_name; elf_first_header_t first_header; elf64_file_header_t file_header; elf_segment_t *segments; elf_section_t *sections; uword *section_by_name; uword *section_by_start_address; elf_symbol_table_t *symbol_tables; elf_relocation_table_t *relocation_tables; char *interpreter; elf64_dynamic_entry_t *dynamic_entries; u8 *dynamic_string_table; u32 dynamic_string_table_section_index; u32 dynamic_symbol_table_section_index; u32 dynamic_symbol_table_index; u32 dynamic_section_index; u16 *versym; u32 versym_section_index; elf_dynamic_version_need_union_t *verneed; u32 verneed_section_index; } elf_main_t; always_inline void elf_main_init (elf_main_t * em) { memset (em, 0, sizeof (em[0])); } always_inline void elf_main_free (elf_main_t * em) { uword i; for (i = 0; i < vec_len (em->segments); i++) vec_free (em->segments[i].contents); vec_free (em->segments); for (i = 0; i < vec_len (em->sections); i++) vec_free (em->sections[i].contents); vec_free (em->sections); hash_free (em->section_by_name); for (i = 0; i < vec_len (em->symbol_tables); i++) elf_symbol_table_free (em->symbol_tables + i); for (i = 0; i < vec_len (em->relocation_tables); i++) elf_relocation_table_free (em->relocation_tables + i); vec_free (em->dynamic_entries); vec_free (em->interpreter); } always_inline void elf_get_segment_contents (elf_main_t * em, void *data, uword segment_index) { elf_segment_t *g = vec_elt_at_index (em->segments, segment_index); if (!g->contents) vec_add (g->contents, data + g->header.file_offset, g->header.memory_size); } always_inline void * elf_get_section_contents (elf_main_t * em, uword section_index, uword elt_size) { elf_section_t *s; void *result; s = vec_elt_at_index (em->sections, section_index); result = 0; if (vec_len (s->contents) > 0) { /* Make vector copy of contents with given element size. */ result = _vec_resize (result, vec_len (s->contents) / elt_size, vec_len (s->contents), /* header_bytes */ 0, /* align */ 0); clib_memcpy (result, s->contents, vec_len (s->contents)); } return result; } always_inline void elf_set_section_contents (elf_main_t * em, uword section_index, void *new_contents, uword n_content_bytes) { elf_section_t *s; s = vec_elt_at_index (em->sections, section_index); vec_free (s->contents); vec_add (s->contents, new_contents, n_content_bytes); } always_inline u8 * elf_section_name (elf_main_t * em, elf_section_t * s) { elf_section_t *es = vec_elt_at_index (em->sections, em-> file_header.section_header_string_table_index); return vec_elt_at_index (es->contents, s->header.name); } always_inline u8 elf_swap_u8 (elf_main_t * em, u8 x) { return x; } always_inline u16 elf_swap_u16 (elf_main_t * em, u16 x) { return em->need_byte_swap ? clib_byte_swap_u16 (x) : x; } always_inline u32 elf_swap_u32 (elf_main_t * em, u32 x) { return em->need_byte_swap ? clib_byte_swap_u32 (x) : x; } always_inline u64 elf_swap_u64 (elf_main_t * em, u64 x) { return em->need_byte_swap ? clib_byte_swap_u64 (x) : x; } #define FORMAT_ELF_MAIN_SYMBOLS (1 << 0) #define FORMAT_ELF_MAIN_RELOCATIONS (1 << 1) #define FORMAT_ELF_MAIN_DYNAMIC (1 << 2) format_function_t format_elf_main; format_function_t format_elf_symbol; clib_error_t *elf_read_file (elf_main_t * em, char *file_name); clib_error_t *elf_write_file (elf_main_t * em, char *file_name); clib_error_t *elf_delete_named_section (elf_main_t * em, char *section_name); clib_error_t *elf_parse (elf_main_t * em, void *data, uword data_bytes); void elf_parse_symbols (elf_main_t * em); clib_error_t *elf_get_section_by_name (elf_main_t * em, char *section_name, elf_section_t ** result); clib_error_t *elf_get_section_by_start_address (elf_main_t * em, uword start_address, elf_section_t ** result); void elf_create_section_with_contents (elf_main_t * em, char *section_name, elf64_section_header_t * header, void *contents, uword n_content_bytes); uword elf_delete_segment_with_type (elf_main_t * em, elf_segment_type_t segment_type); void elf_set_dynamic_entries (elf_main_t * em); #endif /* included_clib_elf_h */ /* * fd.io coding-style-patch-verification: ON * * Local Variables: * eval: (c-set-style "gnu") * End: */