ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab/*
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * CDDL HEADER START
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab *
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * The contents of this file are subject to the terms of the
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * Common Development and Distribution License (the "License").
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * You may not use this file except in compliance with the License.
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab *
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * or http://www.opensolaris.org/os/licensing.
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * See the License for the specific language governing permissions
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * and limitations under the License.
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab *
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * When distributing Covered Code, include this CDDL HEADER in each
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * If applicable, add the following below this CDDL HEADER, with the
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * fields enclosed by brackets "[]" replaced with your own identifying
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * information: Portions Copyright [yyyy] [name of copyright owner]
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab *
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * CDDL HEADER END
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab/*
4f680cc668fa6cf678c531083400ade9a9c7934cAli Bahrami * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * Use is subject to license terms.
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab#include <stdio.h>
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab#include <ctype.h>
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab#include <unistd.h>
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab#include <elfedit.h>
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab#include <strings.h>
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab#include <debug.h>
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab#include <conv.h>
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab#include <str_msg.h>
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab#define MAXNDXSIZE 10
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab/*
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * This module uses shared code for several of the commands.
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * It is sometimes necessary to know which specific command
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * is active.
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66abtypedef enum {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab STR_CMD_T_DUMP = 0, /* str:dump */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab STR_CMD_T_SET = 1, /* str:set */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab STR_CMD_T_ADD = 2, /* str:add */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab STR_CMD_T_ZERO = 3, /* str:zero */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab} STR_CMD_T;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab#ifndef _ELF64
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab/*
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * We supply this function for the msg module. Only one copy is needed.
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66abconst char *
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab_str_msg(Msg mid)
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab{
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab return (gettext(MSG_ORIG(mid)));
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab}
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab#endif
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab/*
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * This function is supplied to elfedit through our elfedit_module_t
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * definition. It translates the opaque elfedit_i18nhdl_t handles
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * in our module interface into the actual strings for elfedit to
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * use.
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab *
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * note:
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * This module uses Msg codes for its i18n handle type.
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * So the translation is simply to use MSG_INTL() to turn
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * it into a string and return it.
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66abstatic const char *
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66abmod_i18nhdl_to_str(elfedit_i18nhdl_t hdl)
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab{
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab Msg msg = (Msg)hdl;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab return (MSG_INTL(msg));
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab}
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab/*
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * The sym_opt_t enum specifies a bit value for every optional
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * argument allowed by a command in this module.
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66abtypedef enum {
cce0e03bb2d07f0fe27cabb93acae9c23655859fab STR_OPT_F_ANY = 1, /* -any: treat any sec. as strtab */
cce0e03bb2d07f0fe27cabb93acae9c23655859fab STR_OPT_F_END = 2, /* -end: zero to end of strtab */
cce0e03bb2d07f0fe27cabb93acae9c23655859fab STR_OPT_F_NOTERM = 4, /* -noterm: str:set won't term string */
cce0e03bb2d07f0fe27cabb93acae9c23655859fab STR_OPT_F_SHNAME = 8, /* -shnam name: section spec. by name */
cce0e03bb2d07f0fe27cabb93acae9c23655859fab STR_OPT_F_SHNDX = 16, /* -shndx ndx: strtab spec. by index */
cce0e03bb2d07f0fe27cabb93acae9c23655859fab STR_OPT_F_SHTYP = 32, /* -shtyp type: section spec. by type */
cce0e03bb2d07f0fe27cabb93acae9c23655859fab STR_OPT_F_STRNDX = 64, /* -strndx: String specified by index */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab} str_opt_t;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab/*
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * A variable of type ARGSTATE is used by each command to maintain
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * information about the string table section being used, and for any
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * auxiliary sections that are related to it.
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66abtypedef struct {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab elfedit_obj_state_t *obj_state;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab str_opt_t optmask; /* Mask of options used */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab int argc; /* # of plain arguments */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab const char **argv; /* Plain arguments */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab struct { /* String table */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab elfedit_section_t *sec;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab Word ndx; /* Table offset if (argc > 0) */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab } str;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab struct { /* Dynamic section */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab elfedit_section_t *sec;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab Dyn *data;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab Word n;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab elfedit_dyn_elt_t strpad;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab } dyn;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab} ARGSTATE;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab/*
cce0e03bb2d07f0fe27cabb93acae9c23655859fab * Given an ELF SHT_ section type constant, shndx_to_strtab() returns
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * one of the following
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66abtypedef enum {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab SHTOSTR_NONE = 0, /* Type can't lead to a string table */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab SHTOSTR_STRTAB = 1, /* type is SHT_STRTAB */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab SHTOSTR_LINK_STRTAB = 2, /* sh_link for type yields strtab */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab SHTOSTR_LINK_SYMTAB = 3, /* sh_link for type yields symtab */
55ef6355bc6375ad080b10b10660e3528e2b7e6aab SHTOSTR_SHF_STRINGS = 4, /* Not strtab, but SHF_STRINGS set */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab} SHTOSTR_T;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
55ef6355bc6375ad080b10b10660e3528e2b7e6aabstatic SHTOSTR_T
55ef6355bc6375ad080b10b10660e3528e2b7e6aabshtype_to_strtab(Word sh_type, Word sh_flags)
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab{
55ef6355bc6375ad080b10b10660e3528e2b7e6aab /*
55ef6355bc6375ad080b10b10660e3528e2b7e6aab * A string table section always leads to itself. A
55ef6355bc6375ad080b10b10660e3528e2b7e6aab * non-string table that has it's SHF_STRINGS section flag
55ef6355bc6375ad080b10b10660e3528e2b7e6aab * set trumps anything else.
55ef6355bc6375ad080b10b10660e3528e2b7e6aab */
55ef6355bc6375ad080b10b10660e3528e2b7e6aab if (sh_type == SHT_STRTAB)
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab return (SHTOSTR_STRTAB);
55ef6355bc6375ad080b10b10660e3528e2b7e6aab if (sh_flags & SHF_STRINGS)
55ef6355bc6375ad080b10b10660e3528e2b7e6aab return (SHTOSTR_SHF_STRINGS);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
55ef6355bc6375ad080b10b10660e3528e2b7e6aab /*
55ef6355bc6375ad080b10b10660e3528e2b7e6aab * Look at non-stringtable section types that can lead to
55ef6355bc6375ad080b10b10660e3528e2b7e6aab * string tables via sh_link.
55ef6355bc6375ad080b10b10660e3528e2b7e6aab */
55ef6355bc6375ad080b10b10660e3528e2b7e6aab switch (sh_type) {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* These sections reference a string table via sh_link */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab case SHT_DYNAMIC:
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab case SHT_SYMTAB:
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab case SHT_DYNSYM:
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab case SHT_SUNW_LDYNSYM:
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab case SHT_SUNW_verdef:
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab case SHT_SUNW_verneed:
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab return (SHTOSTR_LINK_STRTAB);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /*
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * These sections reference a symbol table via sh_link.
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * Symbol tables, in turn, reference a string table
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * via their sh_link.
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab case SHT_HASH:
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab case SHT_REL:
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab case SHT_RELA:
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab case SHT_GROUP:
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab case SHT_SYMTAB_SHNDX:
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab case SHT_SUNW_move:
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab case SHT_SUNW_syminfo:
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab case SHT_SUNW_versym:
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab case SHT_SUNW_symsort:
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab case SHT_SUNW_tlssort:
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab return (SHTOSTR_LINK_SYMTAB);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab }
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* Types that lead to string tables were caught above */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab return (SHTOSTR_NONE);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab}
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab/*
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * Given a section index, attempt to convert it into an index
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * to a string table section.
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66abstatic Word
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66abshndx_to_strtab(elfedit_obj_state_t *obj_state, Word ndx)
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab{
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /*
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * Locate and validate the string table. In the case where
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * a non-string table section is given that references a string
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * table, we will use the referenced table.
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if (ndx < obj_state->os_shnum) {
55ef6355bc6375ad080b10b10660e3528e2b7e6aab Shdr *shdr = obj_state->os_secarr[ndx].sec_shdr;
55ef6355bc6375ad080b10b10660e3528e2b7e6aab
55ef6355bc6375ad080b10b10660e3528e2b7e6aab switch (shtype_to_strtab(shdr->sh_type, shdr->sh_flags)) {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* Sections that reference a string table via sh_link */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab case SHTOSTR_LINK_STRTAB:
55ef6355bc6375ad080b10b10660e3528e2b7e6aab ndx = shdr->sh_link;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab break;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /*
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * Sections that reference a symbol tabel via sh_link,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * which in turn reference a string table via their sh_link.
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab case SHTOSTR_LINK_SYMTAB:
55ef6355bc6375ad080b10b10660e3528e2b7e6aab ndx = shdr->sh_link;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if (ndx < obj_state->os_shnum)
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ndx =
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab obj_state->os_secarr[ndx].sec_shdr->sh_link;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab break;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab }
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab }
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab return (ndx);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab}
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab/*
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * Standard argument processing for string table module
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab *
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * entry
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * obj_state, argc, argv - Standard command arguments
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * optmask - Mask of allowed optional arguments.
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * argstate - Address of ARGSTATE block to be initialized
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab *
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * exit:
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * On success, *argstate is initialized. On error,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * an error is issued and this routine does not return.
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66abstatic void
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66abprocess_args(elfedit_obj_state_t *obj_state, int argc, const char *argv[],
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab STR_CMD_T cmd, ARGSTATE *argstate, int *print_only)
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab{
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab elfedit_getopt_state_t getopt_state;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab elfedit_getopt_ret_t *getopt_ret;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab Word ndx;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab int argc_ok;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab bzero(argstate, sizeof (*argstate));
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab argstate->obj_state = obj_state;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /*
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * By default, we use the section name string table pointed at
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * by the ELF header.
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ndx = obj_state->os_ehdr->e_shstrndx;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab elfedit_getopt_init(&getopt_state, &argc, &argv);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* Add each new option to the options mask */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab while ((getopt_ret = elfedit_getopt(&getopt_state)) != NULL) {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab argstate->optmask |= getopt_ret->gor_idmask;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab switch (getopt_ret->gor_idmask) {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab case STR_OPT_F_SHNAME: /* -shnam name */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ndx = elfedit_name_to_shndx(obj_state,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab getopt_ret->gor_value);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab break;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab case STR_OPT_F_SHNDX: /* -shndx index */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ndx = elfedit_atoui(getopt_ret->gor_value, NULL);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab break;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab case STR_OPT_F_SHTYP: /* -shtyp type */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ndx = elfedit_type_to_shndx(obj_state,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab elfedit_atoconst(getopt_ret->gor_value,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ELFEDIT_CONST_SHT));
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab break;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab }
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab }
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /*
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * Usage error if there are the wrong number of plain arguments.
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab switch (cmd) {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab case STR_CMD_T_DUMP:
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab argc_ok = (argc == 0) || (argc == 1);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab *print_only = 1;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab break;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab case STR_CMD_T_SET:
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab argc_ok = (argc == 1) || (argc == 2);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab *print_only = (argc == 1);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab break;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab case STR_CMD_T_ADD:
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab argc_ok = (argc == 1);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab *print_only = 0;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab break;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab case STR_CMD_T_ZERO:
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /*
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * The second argument (count) and the -end option are
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * mutally exclusive.
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab argc_ok = ((argc == 1) || (argc == 2)) &&
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab !((argc == 2) && (argstate->optmask & STR_OPT_F_END));
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab *print_only = 0;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab break;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab default:
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab argc_ok = 0; /* Unknown command? */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab break;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab }
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if (!argc_ok)
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab elfedit_command_usage();
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* If there may be an arbitrary amount of output, use a pager */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if (argc == 0)
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab elfedit_pager_init();
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* Return the updated values of argc/argv */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab argstate->argc = argc;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab argstate->argv = argv;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
cce0e03bb2d07f0fe27cabb93acae9c23655859fab if (argstate->optmask & STR_OPT_F_ANY) {
cce0e03bb2d07f0fe27cabb93acae9c23655859fab /* Take the arbitrary section */
cce0e03bb2d07f0fe27cabb93acae9c23655859fab argstate->str.sec = elfedit_sec_get(obj_state, ndx);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
cce0e03bb2d07f0fe27cabb93acae9c23655859fab } else {
cce0e03bb2d07f0fe27cabb93acae9c23655859fab /*
cce0e03bb2d07f0fe27cabb93acae9c23655859fab * Locate and validate the string table. In the case where
cce0e03bb2d07f0fe27cabb93acae9c23655859fab * a non-string table section is given that references a string
cce0e03bb2d07f0fe27cabb93acae9c23655859fab * table, we will use the referenced table.
cce0e03bb2d07f0fe27cabb93acae9c23655859fab */
cce0e03bb2d07f0fe27cabb93acae9c23655859fab ndx = shndx_to_strtab(obj_state, ndx);
cce0e03bb2d07f0fe27cabb93acae9c23655859fab
cce0e03bb2d07f0fe27cabb93acae9c23655859fab /*
cce0e03bb2d07f0fe27cabb93acae9c23655859fab * If ndx is a string table, the following will issue the
cce0e03bb2d07f0fe27cabb93acae9c23655859fab * proper debug messages. If it is out of range, or of any
cce0e03bb2d07f0fe27cabb93acae9c23655859fab * other type, an error is issued and it doesn't return.
cce0e03bb2d07f0fe27cabb93acae9c23655859fab */
55ef6355bc6375ad080b10b10660e3528e2b7e6aab argstate->str.sec = elfedit_sec_getstr(obj_state, ndx, 1);
cce0e03bb2d07f0fe27cabb93acae9c23655859fab }
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /*
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * If there is a dynamic section, check its sh_link to the
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * string table index. If these match, then we have the
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * dynamic string table. In that case, fetch the dynamic
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * section and locate the DT_SUNW_STRPAD entry, causing
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * debug messages to be issued.
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab argstate->dyn.sec = NULL;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab elfedit_dyn_elt_init(&argstate->dyn.strpad);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if (obj_state->os_dynndx != SHN_UNDEF) {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab elfedit_section_t *dynsec =
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab &obj_state->os_secarr[obj_state->os_dynndx];
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if ((dynsec->sec_shdr->sh_type == SHT_DYNAMIC) &&
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab (argstate->str.sec->sec_shndx ==
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab dynsec->sec_shdr->sh_link)) {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab argstate->dyn.sec = elfedit_sec_getdyn(obj_state,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab &argstate->dyn.data, &argstate->dyn.n);
4f680cc668fa6cf678c531083400ade9a9c7934cAli Bahrami (void) elfedit_dynstr_getpad(obj_state, dynsec,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab &argstate->dyn.strpad);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /*
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * Does the pad value make sense?
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * Issue debug message and ignore it if not.
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if ((argstate->dyn.strpad.dn_seen != 0) &&
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab (argstate->dyn.strpad.dn_dyn.d_un.d_val >
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab argstate->str.sec->sec_data->d_size)) {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab argstate->dyn.strpad.dn_seen = 0;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab elfedit_msg(ELFEDIT_MSG_DEBUG,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab MSG_INTL(MSG_DEBUG_BADSTRPAD),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab EC_WORD(argstate->str.sec->sec_shndx),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab argstate->str.sec->sec_name,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab EC_XWORD(argstate->dyn.strpad.dn_dyn.
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab d_un.d_val),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab EC_XWORD(argstate->str.sec->
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab sec_data->d_size));
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab }
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab }
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab }
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* Locate the string table offset if argument is present */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if ((argc > 0) && (cmd != STR_CMD_T_ADD)) {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /*
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * If the -strndx option was specified, arg is an index
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * into the string table. Otherwise it is a string
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * to be looked up.
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if (argstate->optmask & STR_OPT_F_STRNDX) {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab argstate->str.ndx = (elfedit_atoui_range(argv[0],
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab MSG_ORIG(MSG_STR_STRING), 0,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab argstate->str.sec->sec_data->d_size - 1, NULL));
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab } else {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if (elfedit_sec_findstr(argstate->str.sec, 0, argv[0],
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab &argstate->str.ndx) == 0)
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab elfedit_msg(ELFEDIT_MSG_ERR,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab MSG_INTL(MSG_ERR_STRNOTFND),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab EC_WORD(argstate->str.sec->sec_shndx),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab argstate->str.sec->sec_name, argv[0]);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab }
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab } else {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab argstate->str.ndx = 0;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab }
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab}
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab/*
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * Print string table values, taking output style into account.
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab *
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * entry:
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * autoprint - If True, output is only produced if the elfedit
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * autoprint flag is set. If False, output is always produced.
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * argstate - State block for current symbol table.
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66abstatic void
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66abprint_strtab(int autoprint, ARGSTATE *argstate)
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab{
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab char index[(MAXNDXSIZE * 2) + 4];
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab elfedit_outstyle_t outstyle;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab const char *str, *limit, *tbl_limit;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab Word ndx;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if (autoprint && ((elfedit_flags() & ELFEDIT_F_AUTOPRINT) == 0))
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab return;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab outstyle = elfedit_outstyle();
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if (outstyle == ELFEDIT_OUTSTYLE_DEFAULT) {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab elfedit_printf(MSG_INTL(MSG_FMT_STRTAB),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab argstate->str.sec->sec_name);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if (argstate->dyn.strpad.dn_seen)
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab elfedit_printf(MSG_INTL(MSG_FMT_DYNSTRPAD),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab EC_WORD(argstate->str.sec->sec_data->d_size -
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab argstate->dyn.strpad.dn_dyn.d_un.d_val),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab EC_WORD(argstate->str.sec->sec_data->d_size - 1),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab EC_WORD(argstate->dyn.strpad.dn_dyn.d_un.d_val));
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab elfedit_printf(MSG_INTL(MSG_FMT_DUMPTITLE));
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab }
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab str = argstate->str.sec->sec_data->d_buf;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab tbl_limit = str + argstate->str.sec->sec_data->d_size;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ndx = argstate->str.ndx;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if (argstate->argc > 0) {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab str += ndx;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /*
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * If first byte is NULL and this is the default output style,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * then we want to display the range of NULL bytes, and we
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * push limit out to the last one in the sequence. Otherwise,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * just display the string.
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if ((*str == '\0') && (outstyle == ELFEDIT_OUTSTYLE_DEFAULT)) {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab limit = str;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab while (((limit + 1) < tbl_limit) &&
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab (*(limit + 1) == '\0'))
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab limit++;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab } else {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab limit = str + strlen(str) + 1;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab }
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab } else {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* Display the entire string table */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab limit = tbl_limit;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab }
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab while (str < limit) {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab Word skip = strlen(str) + 1;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab Word start_ndx;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if (outstyle != ELFEDIT_OUTSTYLE_DEFAULT) {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab elfedit_printf(MSG_ORIG(MSG_FMT_STRNL), str);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab str += skip;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ndx += skip;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab continue;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab }
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab start_ndx = ndx;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if (*str == '\0')
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab while (((str + 1) < limit) && (*(str + 1) == '\0')) {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ndx++;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab str++;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab }
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if (start_ndx != ndx) {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab (void) snprintf(index, sizeof (index),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab MSG_ORIG(MSG_FMT_INDEXRANGE),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab EC_XWORD(start_ndx), EC_XWORD(ndx));
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab } else {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab (void) snprintf(index, sizeof (index),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab MSG_ORIG(MSG_FMT_INDEX), EC_XWORD(ndx));
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab }
cce0e03bb2d07f0fe27cabb93acae9c23655859fab elfedit_printf(MSG_ORIG(MSG_FMT_DUMPENTRY), index);
cce0e03bb2d07f0fe27cabb93acae9c23655859fab elfedit_write(MSG_ORIG(MSG_STR_DQUOTE), MSG_STR_DQUOTE_SIZE);
cce0e03bb2d07f0fe27cabb93acae9c23655859fab if (start_ndx == ndx)
cce0e03bb2d07f0fe27cabb93acae9c23655859fab elfedit_str_to_c_literal(str, elfedit_write);
cce0e03bb2d07f0fe27cabb93acae9c23655859fab elfedit_write(MSG_ORIG(MSG_STR_DQUOTENL),
cce0e03bb2d07f0fe27cabb93acae9c23655859fab MSG_STR_DQUOTENL_SIZE);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab str += skip;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ndx += skip;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab }
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab}
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab/*
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * Command body for str:set, handling the case where the 3rd
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * argument (new-str) is present.
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66abstatic elfedit_cmdret_t
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66abcmd_body_set(ARGSTATE *argstate)
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab{
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab elfedit_section_t *strsec = argstate->str.sec;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab const char *newstr = argstate->argv[1];
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab Word ndx = argstate->str.ndx;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab char *oldstr;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab int i, len, ncp;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab len = strlen(newstr);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ncp = len;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if (!(argstate->optmask & STR_OPT_F_NOTERM))
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ncp++;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* NULL string with no termination? Nothing to do */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if (ncp == 0)
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab return (ELFEDIT_CMDRET_NONE);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* Does it fit? */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if ((ndx + ncp) > strsec->sec_data->d_size)
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab elfedit_msg(ELFEDIT_MSG_ERR, MSG_INTL(MSG_ERR_NOFIT),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab EC_WORD(strsec->sec_shndx), strsec->sec_name,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab EC_WORD(ndx), newstr);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* Does it clobber the final NULL termination? */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if (((ndx + ncp) == strsec->sec_data->d_size) &&
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab (argstate->optmask & STR_OPT_F_NOTERM))
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab elfedit_msg(ELFEDIT_MSG_ERR, MSG_INTL(MSG_ERR_FINALNULL),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab EC_WORD(strsec->sec_shndx), strsec->sec_name,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab EC_WORD(ndx), newstr);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /*
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * strtab[0] is always supposed to contain a NULL byte. You're not
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * supposed to mess with it. We will carry out this operation,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * but with a debug message indicating that it is unorthodox.
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if ((ndx == 0) && (*newstr != '\0'))
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab elfedit_msg(ELFEDIT_MSG_DEBUG, MSG_INTL(MSG_DEBUG_CHGSTR0),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab EC_WORD(strsec->sec_shndx), strsec->sec_name,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab EC_WORD(ndx), newstr);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* Does it alter the existing value? */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab oldstr = ndx + (char *)strsec->sec_data->d_buf;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab for (i = 0; i < ncp; i++)
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if (newstr[i] != oldstr[i])
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab break;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if (i == ncp) { /* No change */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab elfedit_msg(ELFEDIT_MSG_DEBUG, MSG_INTL(MSG_DEBUG_S_OK),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab strsec->sec_shndx, strsec->sec_name, ndx, newstr);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab return (ELFEDIT_CMDRET_NONE);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab }
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /*
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * If the new string is longer than the old one, then it will
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * clobber the start of the following string. The resulting
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * string table is perfectly legal, but issue a debug message
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * letting the user know.
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab i = strlen(oldstr);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if (len > i)
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab elfedit_msg(ELFEDIT_MSG_DEBUG, MSG_INTL(MSG_DEBUG_LONGSTR),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab EC_WORD(strsec->sec_shndx), strsec->sec_name,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab EC_WORD(ndx), len, i);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /*
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * If we have strayed into the reserved part of the dynstr, then
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * update DT_SUNW_STRPAD.
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if (argstate->dyn.strpad.dn_seen) {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab elfedit_dyn_elt_t *strpad = &argstate->dyn.strpad;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab Word new_pad_ndx = ndx + len + 1;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab Word pad_ndx = argstate->str.sec->sec_data->d_size -
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab strpad->dn_dyn.d_un.d_val;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if (new_pad_ndx > pad_ndx) {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab elfedit_msg(ELFEDIT_MSG_DEBUG,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab MSG_INTL(MSG_DEBUG_ADDDYNSTR),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab EC_WORD(strsec->sec_shndx), strsec->sec_name,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab EC_WORD(ndx), EC_WORD(new_pad_ndx - pad_ndx),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab EC_WORD(strpad->dn_dyn.d_un.d_val),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab newstr);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab strpad->dn_dyn.d_un.d_val =
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab argstate->dyn.data[strpad->dn_ndx].d_un.d_val =
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab (argstate->str.sec->sec_data->d_size - new_pad_ndx);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab elfedit_modified_data(argstate->dyn.sec);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab }
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab }
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab elfedit_msg(ELFEDIT_MSG_DEBUG, MSG_INTL(MSG_DEBUG_S_CHG),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab strsec->sec_shndx, strsec->sec_name, ndx, len, oldstr, newstr);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab bcopy(newstr, oldstr, ncp);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab return (ELFEDIT_CMDRET_MOD);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab}
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab/*
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * Command body for str:zero
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66abstatic elfedit_cmdret_t
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66abcmd_body_zero(ARGSTATE *argstate)
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab{
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab elfedit_section_t *strsec = argstate->str.sec;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab Word count;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab Word ndx = argstate->str.ndx;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab char *oldstr = ndx + (char *)strsec->sec_data->d_buf;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab Word i;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* How many bytes to zero? */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if (argstate->optmask & STR_OPT_F_END)
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab count = strsec->sec_data->d_size - argstate->str.ndx;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab else if (argstate->argc == 2)
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab count = elfedit_atoui_range(argstate->argv[1],
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab MSG_ORIG(MSG_STR_COUNT), 0,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab argstate->str.sec->sec_data->d_size - argstate->str.ndx,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab NULL);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab else
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab count = strlen(oldstr);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* Does it alter the existing value? */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab for (i = 0; i < count; i++)
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if (oldstr[i] != '\0')
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab break;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if (i == count) { /* No change */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab elfedit_msg(ELFEDIT_MSG_DEBUG, MSG_INTL(MSG_DEBUG_Z_OK),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab strsec->sec_shndx, strsec->sec_name, ndx);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab return (ELFEDIT_CMDRET_NONE);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab }
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab elfedit_msg(ELFEDIT_MSG_DEBUG, MSG_INTL(MSG_DEBUG_Z_CHG),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab strsec->sec_shndx, strsec->sec_name, ndx, count);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab bzero(oldstr, count);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab return (ELFEDIT_CMDRET_MOD);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab}
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab/*
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * Common body for the str: module commands.
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab *
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * entry:
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * cmd - One of the STR_CMD_T_* constants listed above, specifying
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * which command to implement.
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * obj_state, argc, argv - Standard command arguments
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66abstatic elfedit_cmdret_t
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66abcmd_body(STR_CMD_T cmd, elfedit_obj_state_t *obj_state,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab int argc, const char *argv[])
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab{
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ARGSTATE argstate;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab elfedit_cmdret_t ret = ELFEDIT_CMDRET_NONE;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab int print_only;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab process_args(obj_state, argc, argv, cmd, &argstate, &print_only);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /*
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * If this call call does not change data, display the current
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * value(s) and return.
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if (print_only) {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab print_strtab(0, &argstate);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab return (ELFEDIT_CMDRET_NONE);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab }
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab switch (cmd) {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* NOTE: STR_CMD_T_DUMP can't get here --- it's always print_only */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab case STR_CMD_T_SET:
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ret = cmd_body_set(&argstate);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab break;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab case STR_CMD_T_ADD:
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab argstate.str.ndx = elfedit_strtab_insert(obj_state,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab argstate.str.sec, argstate.dyn.sec, argstate.argv[0]);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab break;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab case STR_CMD_T_ZERO:
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ret = cmd_body_zero(&argstate);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab break;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab }
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /*
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * If we modified the strtab section, tell libelf.
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if (ret == ELFEDIT_CMDRET_MOD)
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab elfedit_modified_data(argstate.str.sec);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* Do autoprint */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab print_strtab(1, &argstate);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab return (ret);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab}
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab/*
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * Command completion functions for the various commands
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66abstatic void
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66abadd_shtyp_match(Word sh_type, void *cpldata)
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab{
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab char buf[128];
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab const char *s;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab char *s2;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab s = elfedit_atoconst_value_to_str(ELFEDIT_CONST_SHT, sh_type, 0);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab elfedit_cpl_match(cpldata, s, 1);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /*
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * To get the informal tag names that are lowercase
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * and lack the leading SHT_, we copy the string we
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * have into a buffer and process it.
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if (strlen(s) < 4)
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab return;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab (void) strlcpy(buf, s + 4, sizeof (buf));
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab for (s2 = buf; *s2 != '\0'; s2++)
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if (isupper(*s2))
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab *s2 = tolower(*s2);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab elfedit_cpl_match(cpldata, buf, 1);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab}
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab/*
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * Handle filling in the values for -shnam, -shndx, and -shtyp options.
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab/*ARGSUSED*/
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66abstatic void
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66abcpl_sh_opt(elfedit_obj_state_t *obj_state, void *cpldata, int argc,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab const char *argv[], int num_opt)
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab{
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab enum { NAME, INDEX, TYPE } op;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab elfedit_section_t *sec;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab Word ndx;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if ((argc != num_opt) || (argc < 2))
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab return;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if (strcmp(argv[argc - 2], MSG_ORIG(MSG_STR_MINUS_SHNAM)) == 0) {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab op = NAME;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab } else if (strcmp(argv[argc - 2], MSG_ORIG(MSG_STR_MINUS_SHNDX)) == 0) {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab op = INDEX;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab } else if (strcmp(argv[argc - 2], MSG_ORIG(MSG_STR_MINUS_SHTYP)) == 0) {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab op = TYPE;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if (obj_state == NULL) { /* No object available */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab elfedit_atoui_sym_t *atoui_sym;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab atoui_sym = elfedit_const_to_atoui(ELFEDIT_CONST_SHT);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab for (; atoui_sym->sym_name != NULL; atoui_sym++)
55ef6355bc6375ad080b10b10660e3528e2b7e6aab if (shtype_to_strtab(atoui_sym->sym_value, 0) !=
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab SHTOSTR_NONE)
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab elfedit_cpl_match(cpldata,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab atoui_sym->sym_name, 1);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab }
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab } else {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab return;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab }
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if (obj_state == NULL) /* No object available */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab return;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /*
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * Loop over the section headers and supply command completion
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * for the items in the file that can yield a string table.
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab sec = obj_state->os_secarr;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab for (ndx = 0; ndx < obj_state->os_shnum; ndx++, sec++) {
55ef6355bc6375ad080b10b10660e3528e2b7e6aab Shdr *shdr = sec->sec_shdr;
55ef6355bc6375ad080b10b10660e3528e2b7e6aab SHTOSTR_T shtostr_type;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
55ef6355bc6375ad080b10b10660e3528e2b7e6aab shtostr_type = shtype_to_strtab(shdr->sh_type, shdr->sh_flags);
55ef6355bc6375ad080b10b10660e3528e2b7e6aab if (shtostr_type == SHTOSTR_NONE)
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab continue;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab switch (op) {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab case NAME:
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab elfedit_cpl_match(cpldata, sec->sec_name, 0);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab break;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab case INDEX:
55ef6355bc6375ad080b10b10660e3528e2b7e6aab elfedit_cpl_ndx(cpldata, sec->sec_shndx);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab break;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab case TYPE:
55ef6355bc6375ad080b10b10660e3528e2b7e6aab if (shtostr_type != SHTOSTR_SHF_STRINGS)
55ef6355bc6375ad080b10b10660e3528e2b7e6aab add_shtyp_match(shdr->sh_type, cpldata);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab break;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab }
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab }
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab}
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab/*
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * Most of the commands accept an -shXXX option for the string table
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * and a string first argument. This routine examines which argument
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * is being processed, and supplies completion for these items.
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66abstatic void
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66abcpl_sec_str(elfedit_obj_state_t *obj_state, void *cpldata, int argc,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab const char *argv[], int num_opt)
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab{
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab const char *str, *limit;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab elfedit_section_t *sec;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab Word strtab_ndx;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab Word ndx;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* Handle -shXXX options */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab cpl_sh_opt(obj_state, cpldata, argc, argv, num_opt);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* Without object state, there's no data to work from */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if (obj_state == NULL)
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab return;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* If not first plain arg, return */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if (argc != (num_opt + 1))
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab return;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /*
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * Look at the options, looking for two things:
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * 1) A -shXXX option specifying a section. If so, turn that
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * into a section index if possible.
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * 2) Was -strndx used? If so, we are looking at an integer
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * value and have nothing to complete.
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab strtab_ndx = obj_state->os_ehdr->e_shstrndx;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab for (ndx = 0; ndx < num_opt; ndx++) {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if (strcmp(argv[ndx], MSG_ORIG(MSG_STR_MINUS_STRNDX)) == 0)
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab return;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if ((ndx+1) < num_opt) {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if (strcmp(argv[ndx],
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab MSG_ORIG(MSG_STR_MINUS_SHNAM)) == 0) {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab Word i;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab for (i = 1; i < obj_state->os_shnum; i++)
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if (strcmp(obj_state->os_secarr[i].
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab sec_name, argv[ndx+1]) == 0) {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab strtab_ndx = i;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab break;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab }
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab } else if (strcmp(argv[ndx],
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab MSG_ORIG(MSG_STR_MINUS_SHNDX)) == 0) {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab elfedit_atoui_t val;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if (elfedit_atoui2(argv[ndx+1], NULL,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab &val) != 0)
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab strtab_ndx = val;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab } else if (strcmp(argv[ndx],
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab MSG_ORIG(MSG_STR_MINUS_SHTYP)) == 0) {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab elfedit_atoui_t sh_type;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab Word i;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if (elfedit_atoconst2(argv[ndx+1],
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ELFEDIT_CONST_SHT, &sh_type) == 0)
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab continue;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab for (i = 1; i < obj_state->os_shnum; i++)
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if (obj_state->os_secarr[i].sec_shdr->
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab sh_type == sh_type) {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab strtab_ndx = i;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab break;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab }
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab }
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab }
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab }
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /*
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * Locate and validate the string table. In the case where
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * a non-string table section is given that references a string
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * table, we will use the referenced table.
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab strtab_ndx = shndx_to_strtab(obj_state, strtab_ndx);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if ((strtab_ndx >= obj_state->os_shnum) ||
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab (obj_state->os_secarr[strtab_ndx].sec_shdr->sh_type != SHT_STRTAB))
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab return;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab sec = &obj_state->os_secarr[strtab_ndx];
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab str = sec->sec_data->d_buf;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab limit = str + sec->sec_data->d_size;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab while (str < limit) {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab if (*str != '\0')
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab elfedit_cpl_match(cpldata, str, 0);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab str += strlen(str) + 1;
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab }
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab}
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab/*
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab * Implementation functions for the commands
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66abstatic elfedit_cmdret_t
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66abcmd_dump(elfedit_obj_state_t *obj_state, int argc, const char *argv[])
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab{
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab return (cmd_body(STR_CMD_T_DUMP, obj_state, argc, argv));
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab}
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66abstatic elfedit_cmdret_t
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66abcmd_set(elfedit_obj_state_t *obj_state, int argc, const char *argv[])
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab{
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab return (cmd_body(STR_CMD_T_SET, obj_state, argc, argv));
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab}
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66abstatic elfedit_cmdret_t
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66abcmd_add(elfedit_obj_state_t *obj_state, int argc, const char *argv[])
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab{
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab return (cmd_body(STR_CMD_T_ADD, obj_state, argc, argv));
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab}
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66abstatic elfedit_cmdret_t
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66abcmd_zero(elfedit_obj_state_t *obj_state, int argc, const char *argv[])
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab{
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab return (cmd_body(STR_CMD_T_ZERO, obj_state, argc, argv));
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab}
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab/*ARGSUSED*/
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66abelfedit_module_t *
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66abelfedit_init(elfedit_module_version_t version)
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab{
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* str:dump */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab static const char *name_dump[] = {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab MSG_ORIG(MSG_CMD_DUMP),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab MSG_ORIG(MSG_STR_EMPTY), /* "" makes this the default command */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab NULL
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab };
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab static elfedit_cmd_optarg_t opt_dump[] = {
cce0e03bb2d07f0fe27cabb93acae9c23655859fab { MSG_ORIG(MSG_STR_MINUS_ANY),
cce0e03bb2d07f0fe27cabb93acae9c23655859fab /* MSG_INTL(MSG_OPTDESC_ANY) */
cce0e03bb2d07f0fe27cabb93acae9c23655859fab ELFEDIT_I18NHDL(MSG_OPTDESC_ANY), 0,
cce0e03bb2d07f0fe27cabb93acae9c23655859fab STR_OPT_F_ANY, 0 },
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { ELFEDIT_STDOA_OPT_O, NULL,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ELFEDIT_CMDOA_F_INHERIT, 0, 0 },
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { MSG_ORIG(MSG_STR_MINUS_SHNAM),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* MSG_INTL(MSG_OPTDESC_SHNAM) */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ELFEDIT_I18NHDL(MSG_OPTDESC_SHNAM), ELFEDIT_CMDOA_F_VALUE,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab STR_OPT_F_SHNAME, STR_OPT_F_SHNDX | STR_OPT_F_SHTYP },
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { MSG_ORIG(MSG_STR_NAME), NULL, 0 },
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { MSG_ORIG(MSG_STR_MINUS_SHNDX),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* MSG_INTL(MSG_OPTDESC_SHNDX) */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ELFEDIT_I18NHDL(MSG_OPTDESC_SHNDX), ELFEDIT_CMDOA_F_VALUE,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab STR_OPT_F_SHNDX, STR_OPT_F_SHNAME | STR_OPT_F_SHTYP },
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { MSG_ORIG(MSG_STR_INDEX), NULL, 0 },
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { MSG_ORIG(MSG_STR_MINUS_SHTYP),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* MSG_INTL(MSG_OPTDESC_SHTYP) */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ELFEDIT_I18NHDL(MSG_OPTDESC_SHTYP), ELFEDIT_CMDOA_F_VALUE,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab STR_OPT_F_SHTYP, STR_OPT_F_SHNAME | STR_OPT_F_SHNDX },
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { MSG_ORIG(MSG_STR_TYPE), NULL, 0 },
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { MSG_ORIG(MSG_STR_MINUS_STRNDX),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* MSG_INTL(MSG_OPTDESC_STRNDX) */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ELFEDIT_I18NHDL(MSG_OPTDESC_STRNDX), 0,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab STR_OPT_F_STRNDX, 0 },
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { NULL }
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab };
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab static elfedit_cmd_optarg_t arg_dump[] = {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { MSG_ORIG(MSG_STR_STRING),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* MSG_INTL(MSG_A1_STRING) */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ELFEDIT_I18NHDL(MSG_A1_STRING),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ELFEDIT_CMDOA_F_OPT },
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { NULL }
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab };
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* str:set */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab static const char *name_set[] = {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab MSG_ORIG(MSG_CMD_SET), NULL };
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab static elfedit_cmd_optarg_t opt_set[] = {
cce0e03bb2d07f0fe27cabb93acae9c23655859fab { MSG_ORIG(MSG_STR_MINUS_ANY),
cce0e03bb2d07f0fe27cabb93acae9c23655859fab /* MSG_INTL(MSG_OPTDESC_ANY) */
cce0e03bb2d07f0fe27cabb93acae9c23655859fab ELFEDIT_I18NHDL(MSG_OPTDESC_ANY), 0,
cce0e03bb2d07f0fe27cabb93acae9c23655859fab STR_OPT_F_ANY, 0 },
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { ELFEDIT_STDOA_OPT_O, NULL,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ELFEDIT_CMDOA_F_INHERIT, 0, 0 },
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { MSG_ORIG(MSG_STR_MINUS_NOTERM),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* MSG_INTL(MSG_OPTDESC_NOTERM) */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ELFEDIT_I18NHDL(MSG_OPTDESC_NOTERM), 0,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab STR_OPT_F_NOTERM, 0 },
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { MSG_ORIG(MSG_STR_MINUS_SHNAM),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* MSG_INTL(MSG_OPTDESC_SHNAM) */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ELFEDIT_I18NHDL(MSG_OPTDESC_SHNAM), ELFEDIT_CMDOA_F_VALUE,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab STR_OPT_F_SHNAME, STR_OPT_F_SHNDX | STR_OPT_F_SHTYP },
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { MSG_ORIG(MSG_STR_NAME), NULL, 0 },
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { MSG_ORIG(MSG_STR_MINUS_SHNDX),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* MSG_INTL(MSG_OPTDESC_SHNDX) */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ELFEDIT_I18NHDL(MSG_OPTDESC_SHNDX), ELFEDIT_CMDOA_F_VALUE,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab STR_OPT_F_SHNDX, STR_OPT_F_SHNAME | STR_OPT_F_SHTYP },
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { MSG_ORIG(MSG_STR_INDEX), NULL, 0 },
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { MSG_ORIG(MSG_STR_MINUS_SHTYP),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* MSG_INTL(MSG_OPTDESC_SHTYP) */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ELFEDIT_I18NHDL(MSG_OPTDESC_SHTYP), ELFEDIT_CMDOA_F_VALUE,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab STR_OPT_F_SHTYP, STR_OPT_F_SHNAME | STR_OPT_F_SHNDX },
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { MSG_ORIG(MSG_STR_TYPE), NULL, 0 },
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { MSG_ORIG(MSG_STR_MINUS_STRNDX),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* MSG_INTL(MSG_OPTDESC_STRNDX) */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ELFEDIT_I18NHDL(MSG_OPTDESC_STRNDX), 0,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab STR_OPT_F_STRNDX, 0 },
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { NULL }
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab };
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab static elfedit_cmd_optarg_t arg_set[] = {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { MSG_ORIG(MSG_STR_STRING),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* MSG_INTL(MSG_A1_STRING) */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ELFEDIT_I18NHDL(MSG_A1_STRING),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab 0 },
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { MSG_ORIG(MSG_STR_NEWSTRING),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* MSG_INTL(MSG_A2_NEWSTRING) */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ELFEDIT_I18NHDL(MSG_A2_NEWSTRING),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ELFEDIT_CMDOA_F_OPT },
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { NULL }
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab };
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* str:add */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab static const char *name_add[] = {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab MSG_ORIG(MSG_CMD_ADD), NULL };
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab static elfedit_cmd_optarg_t opt_add[] = {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { ELFEDIT_STDOA_OPT_O, NULL,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ELFEDIT_CMDOA_F_INHERIT, 0, 0 },
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { MSG_ORIG(MSG_STR_MINUS_SHNAM),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* MSG_INTL(MSG_OPTDESC_SHNAM) */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ELFEDIT_I18NHDL(MSG_OPTDESC_SHNAM), ELFEDIT_CMDOA_F_VALUE,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab STR_OPT_F_SHNAME, STR_OPT_F_SHNDX | STR_OPT_F_SHTYP },
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { MSG_ORIG(MSG_STR_NAME), NULL, 0 },
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { MSG_ORIG(MSG_STR_MINUS_SHNDX),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* MSG_INTL(MSG_OPTDESC_SHNDX) */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ELFEDIT_I18NHDL(MSG_OPTDESC_SHNDX), ELFEDIT_CMDOA_F_VALUE,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab STR_OPT_F_SHNDX, STR_OPT_F_SHNAME | STR_OPT_F_SHTYP },
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { MSG_ORIG(MSG_STR_INDEX), NULL, 0 },
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { MSG_ORIG(MSG_STR_MINUS_SHTYP),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* MSG_INTL(MSG_OPTDESC_SHTYP) */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ELFEDIT_I18NHDL(MSG_OPTDESC_SHTYP), ELFEDIT_CMDOA_F_VALUE,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab STR_OPT_F_SHTYP, STR_OPT_F_SHNAME | STR_OPT_F_SHNDX },
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { MSG_ORIG(MSG_STR_TYPE), NULL, 0 },
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { NULL }
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab };
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab static elfedit_cmd_optarg_t arg_add[] = {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { MSG_ORIG(MSG_STR_NEWSTRING),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* MSG_INTL(MSG_A1_NEWSTRING) */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ELFEDIT_I18NHDL(MSG_A1_NEWSTRING),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab 0 },
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { NULL }
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab };
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* str:zero */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab static const char *name_zero[] = {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab MSG_ORIG(MSG_CMD_ZERO), NULL };
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab static elfedit_cmd_optarg_t opt_zero[] = {
cce0e03bb2d07f0fe27cabb93acae9c23655859fab { MSG_ORIG(MSG_STR_MINUS_ANY),
cce0e03bb2d07f0fe27cabb93acae9c23655859fab /* MSG_INTL(MSG_OPTDESC_ANY) */
cce0e03bb2d07f0fe27cabb93acae9c23655859fab ELFEDIT_I18NHDL(MSG_OPTDESC_ANY), 0,
cce0e03bb2d07f0fe27cabb93acae9c23655859fab STR_OPT_F_ANY, 0 },
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { ELFEDIT_STDOA_OPT_O, NULL,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ELFEDIT_CMDOA_F_INHERIT, 0, 0 },
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { MSG_ORIG(MSG_STR_MINUS_SHNAM),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* MSG_INTL(MSG_OPTDESC_SHNAM) */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ELFEDIT_I18NHDL(MSG_OPTDESC_SHNAM), ELFEDIT_CMDOA_F_VALUE,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab STR_OPT_F_SHNAME, STR_OPT_F_SHNDX | STR_OPT_F_SHTYP },
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { MSG_ORIG(MSG_STR_NAME), NULL, 0 },
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { MSG_ORIG(MSG_STR_MINUS_SHNDX),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* MSG_INTL(MSG_OPTDESC_SHNDX) */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ELFEDIT_I18NHDL(MSG_OPTDESC_SHNDX), ELFEDIT_CMDOA_F_VALUE,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab STR_OPT_F_SHNDX, STR_OPT_F_SHNAME | STR_OPT_F_SHTYP },
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { MSG_ORIG(MSG_STR_INDEX), NULL, 0 },
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { MSG_ORIG(MSG_STR_MINUS_SHTYP),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* MSG_INTL(MSG_OPTDESC_SHTYP) */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ELFEDIT_I18NHDL(MSG_OPTDESC_SHTYP), ELFEDIT_CMDOA_F_VALUE,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab STR_OPT_F_SHTYP, STR_OPT_F_SHNAME | STR_OPT_F_SHNDX },
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { MSG_ORIG(MSG_STR_TYPE), NULL, 0 },
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { MSG_ORIG(MSG_STR_MINUS_STRNDX),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* MSG_INTL(MSG_OPTDESC_STRNDX) */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ELFEDIT_I18NHDL(MSG_OPTDESC_STRNDX), 0,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab STR_OPT_F_STRNDX, 0 },
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { MSG_ORIG(MSG_STR_MINUS_END),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* MSG_INTL(MSG_OPTDESC_END) */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ELFEDIT_I18NHDL(MSG_OPTDESC_END), 0,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab STR_OPT_F_END, 0 },
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { NULL }
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab };
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab static elfedit_cmd_optarg_t arg_zero[] = {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { MSG_ORIG(MSG_STR_STRING),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* MSG_INTL(MSG_A1_STRING) */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ELFEDIT_I18NHDL(MSG_A1_STRING),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab 0 },
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { MSG_ORIG(MSG_STR_COUNT),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* MSG_INTL(MSG_A2_COUNT) */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ELFEDIT_I18NHDL(MSG_A2_COUNT),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ELFEDIT_CMDOA_F_OPT },
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { NULL }
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab };
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab static elfedit_cmd_t cmds[] = {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* str:dump */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { cmd_dump, cpl_sec_str, name_dump,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* MSG_INTL(MSG_DESC_DUMP) */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ELFEDIT_I18NHDL(MSG_DESC_DUMP),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* MSG_INTL(MSG_HELP_DUMP) */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ELFEDIT_I18NHDL(MSG_HELP_DUMP),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab opt_dump, arg_dump },
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* str:set */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { cmd_set, cpl_sec_str, name_set,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* MSG_INTL(MSG_DESC_SET) */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ELFEDIT_I18NHDL(MSG_DESC_SET),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* MSG_INTL(MSG_HELP_SET) */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ELFEDIT_I18NHDL(MSG_HELP_SET),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab opt_set, arg_set },
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* str:add */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { cmd_add, cpl_sh_opt, name_add,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* MSG_INTL(MSG_DESC_ADD) */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ELFEDIT_I18NHDL(MSG_DESC_ADD),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* MSG_INTL(MSG_HELP_ADD) */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ELFEDIT_I18NHDL(MSG_HELP_ADD),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab opt_add, arg_add },
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* str:zero */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { cmd_zero, cpl_sec_str, name_zero,
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* MSG_INTL(MSG_DESC_ZERO) */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ELFEDIT_I18NHDL(MSG_DESC_ZERO),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* MSG_INTL(MSG_HELP_ZERO) */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ELFEDIT_I18NHDL(MSG_HELP_ZERO),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab opt_zero, arg_zero },
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab { NULL }
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab };
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab static elfedit_module_t module = {
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ELFEDIT_VER_CURRENT, MSG_ORIG(MSG_MOD_NAME),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab /* MSG_INTL(MSG_MOD_DESC) */
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab ELFEDIT_I18NHDL(MSG_MOD_DESC),
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab cmds, mod_i18nhdl_to_str };
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab return (&module);
ad212f6fd387c78d9e1507c5d58c58eb9bdefa66ab}