1d29b2c44Sab /*
2d29b2c44Sab * CDDL HEADER START
3d29b2c44Sab *
4d29b2c44Sab * The contents of this file are subject to the terms of the
5d29b2c44Sab * Common Development and Distribution License (the "License").
6d29b2c44Sab * You may not use this file except in compliance with the License.
7d29b2c44Sab *
8d29b2c44Sab * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9d29b2c44Sab * or http://www.opensolaris.org/os/licensing.
10d29b2c44Sab * See the License for the specific language governing permissions
11d29b2c44Sab * and limitations under the License.
12d29b2c44Sab *
13d29b2c44Sab * When distributing Covered Code, include this CDDL HEADER in each
14d29b2c44Sab * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15d29b2c44Sab * If applicable, add the following below this CDDL HEADER, with the
16d29b2c44Sab * fields enclosed by brackets "[]" replaced with your own identifying
17d29b2c44Sab * information: Portions Copyright [yyyy] [name of copyright owner]
18d29b2c44Sab *
19d29b2c44Sab * CDDL HEADER END
20d29b2c44Sab */
21d29b2c44Sab
22d29b2c44Sab /*
234f680cc6SAli Bahrami * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24d29b2c44Sab * Use is subject to license terms.
25d29b2c44Sab */
26d29b2c44Sab
27d29b2c44Sab #include <stdio.h>
28d29b2c44Sab #include <ctype.h>
29d29b2c44Sab #include <elfedit.h>
30d29b2c44Sab #include <sys/elf_SPARC.h>
31d29b2c44Sab #include <sys/elf_amd64.h>
32d29b2c44Sab #include <strings.h>
33d29b2c44Sab #include <conv.h>
34d29b2c44Sab #include <debug.h>
35d29b2c44Sab #include <ehdr_msg.h>
36d29b2c44Sab
37d29b2c44Sab
38d29b2c44Sab
39d29b2c44Sab
40d29b2c44Sab /*
41d29b2c44Sab * This module handles changes to the ELF header
42d29b2c44Sab */
43d29b2c44Sab
44d29b2c44Sab
45d29b2c44Sab
46d29b2c44Sab /*
47d29b2c44Sab * This module uses shared code for several of the commands.
48d29b2c44Sab * It is sometimes necessary to know which specific command
49d29b2c44Sab * is active.
50d29b2c44Sab */
51d29b2c44Sab typedef enum {
52d29b2c44Sab /* Dump command, used as module default to display ELF header */
53d29b2c44Sab EHDR_CMD_T_DUMP = 0, /* ehdr:dump */
54d29b2c44Sab
55d29b2c44Sab /* Commands that correspond directly to ELF header fields */
56d29b2c44Sab EHDR_CMD_T_E_IDENT = 1, /* ehdr:e_ident */
57d29b2c44Sab EHDR_CMD_T_E_TYPE = 2, /* ehdr:e_type */
58d29b2c44Sab EHDR_CMD_T_E_MACHINE = 3, /* ehdr:e_machine */
59d29b2c44Sab EHDR_CMD_T_E_VERSION = 4, /* ehdr:e_version */
60d29b2c44Sab EHDR_CMD_T_E_ENTRY = 5, /* ehdr:e_entry */
61d29b2c44Sab EHDR_CMD_T_E_PHOFF = 6, /* ehdr:e_phoff */
62d29b2c44Sab EHDR_CMD_T_E_SHOFF = 7, /* ehdr:e_shoff */
63d29b2c44Sab EHDR_CMD_T_E_FLAGS = 8, /* ehdr:e_flags */
64d29b2c44Sab EHDR_CMD_T_E_EHSIZE = 9, /* ehdr:e_ehsize */
65d29b2c44Sab EHDR_CMD_T_E_PHENTSIZE = 10, /* ehdr:e_phentsize */
66d29b2c44Sab EHDR_CMD_T_E_PHNUM = 11, /* ehdr:e_phnum */
67d29b2c44Sab EHDR_CMD_T_E_SHENTSIZE = 12, /* ehdr:e_shentsize */
68d29b2c44Sab EHDR_CMD_T_E_SHNUM = 13, /* ehdr:e_shnum */
69d29b2c44Sab EHDR_CMD_T_E_SHSTRNDX = 14, /* ehdr:e_shstrndx */
70d29b2c44Sab
71d29b2c44Sab /* Commands that correspond to the e_ident[] array in ELF hdr */
72d29b2c44Sab EHDR_CMD_T_EI_MAG0 = 15, /* ehdr:ei_mag0 */
73d29b2c44Sab EHDR_CMD_T_EI_MAG1 = 16, /* ehdr:ei_mag1 */
74d29b2c44Sab EHDR_CMD_T_EI_MAG2 = 17, /* ehdr:ei_mag2 */
75d29b2c44Sab EHDR_CMD_T_EI_MAG3 = 18, /* ehdr:ei_mag3 */
76d29b2c44Sab EHDR_CMD_T_EI_CLASS = 19, /* ehdr:ei_class */
77d29b2c44Sab EHDR_CMD_T_EI_DATA = 20, /* ehdr:ei_data */
78d29b2c44Sab EHDR_CMD_T_EI_VERSION = 21, /* ehdr:ei_version */
79d29b2c44Sab EHDR_CMD_T_EI_OSABI = 22, /* ehdr:ei_osabi */
80d29b2c44Sab EHDR_CMD_T_EI_ABIVERSION = 23 /* ehdr:ei_abiversion */
81d29b2c44Sab } EHDR_CMD_T;
82d29b2c44Sab
83d29b2c44Sab
84d29b2c44Sab
85d29b2c44Sab
86d29b2c44Sab
87d29b2c44Sab
88d29b2c44Sab #ifndef _ELF64
89d29b2c44Sab /*
90d29b2c44Sab * We supply this function for the msg module
91d29b2c44Sab */
92d29b2c44Sab const char *
_ehdr_msg(Msg mid)93d29b2c44Sab _ehdr_msg(Msg mid)
94d29b2c44Sab {
95d29b2c44Sab return (gettext(MSG_ORIG(mid)));
96d29b2c44Sab }
97d29b2c44Sab #endif
98d29b2c44Sab
99d29b2c44Sab
100d29b2c44Sab /*
101d29b2c44Sab * This function is supplied to elfedit through our elfedit_module_t
102d29b2c44Sab * definition. It translates the opaque elfedit_i18nhdl_t handles
103d29b2c44Sab * in our module interface into the actual strings for elfedit to
104d29b2c44Sab * use.
105d29b2c44Sab *
106d29b2c44Sab * note:
107d29b2c44Sab * This module uses Msg codes for its i18n handle type.
108d29b2c44Sab * So the translation is simply to use MSG_INTL() to turn
109d29b2c44Sab * it into a string and return it.
110d29b2c44Sab */
111d29b2c44Sab static const char *
mod_i18nhdl_to_str(elfedit_i18nhdl_t hdl)112d29b2c44Sab mod_i18nhdl_to_str(elfedit_i18nhdl_t hdl)
113d29b2c44Sab {
114d29b2c44Sab Msg msg = (Msg)hdl;
115d29b2c44Sab
116d29b2c44Sab return (MSG_INTL(msg));
117d29b2c44Sab }
118d29b2c44Sab
119d29b2c44Sab
120d29b2c44Sab
121d29b2c44Sab /*
122d29b2c44Sab * The ehdr_opt_t enum specifies a bit value for every optional
123d29b2c44Sab * argument allowed by a command in this module.
124d29b2c44Sab */
125d29b2c44Sab typedef enum {
126d29b2c44Sab EHDR_OPT_F_AND = 1, /* -and: AND (&) values to dest */
127d29b2c44Sab EHDR_OPT_F_CMP = 2, /* -cmp: Complement (~) values */
128d29b2c44Sab EHDR_OPT_F_OR = 4, /* -or: OR (|) values to dest */
129d29b2c44Sab EHDR_OPT_F_SHNDX = 8, /* -shndx: sec argument is index of */
130d29b2c44Sab /* section, not name */
131d29b2c44Sab EHDR_OPT_F_SHTYP = 16 /* -shtyp: sec argument is type of */
132d29b2c44Sab /* section, not name */
133d29b2c44Sab } ehdr_opt_t;
134d29b2c44Sab
135d29b2c44Sab
136d29b2c44Sab /*
137d29b2c44Sab * A variable of type ARGSTATE is used by each command to maintain
138d29b2c44Sab * information about the arguments and related things. It is
139d29b2c44Sab * initialized by process_args(), and used by the other routines.
140d29b2c44Sab */
141d29b2c44Sab typedef struct {
142d29b2c44Sab elfedit_obj_state_t *obj_state;
143*9320f495SToomas Soome ehdr_opt_t optmask; /* Mask of options used */
144d29b2c44Sab int argc; /* # of plain arguments */
145d29b2c44Sab const char **argv; /* Plain arguments */
146d29b2c44Sab } ARGSTATE;
147d29b2c44Sab
148d29b2c44Sab
149d29b2c44Sab
150d29b2c44Sab /*
151d29b2c44Sab * Standard argument processing for ehdr module
152d29b2c44Sab *
153d29b2c44Sab * entry
154d29b2c44Sab * obj_state, argc, argv - Standard command arguments
155d29b2c44Sab * argstate - Address of ARGSTATE block to be initialized
156d29b2c44Sab *
157d29b2c44Sab * exit:
158d29b2c44Sab * On success, *argstate is initialized. On error,
159d29b2c44Sab * an error is issued and this routine does not return.
160d29b2c44Sab */
161d29b2c44Sab static void
process_args(elfedit_obj_state_t * obj_state,int argc,const char * argv[],ARGSTATE * argstate)162d29b2c44Sab process_args(elfedit_obj_state_t *obj_state, int argc, const char *argv[],
163d29b2c44Sab ARGSTATE *argstate)
164d29b2c44Sab {
165d29b2c44Sab elfedit_getopt_state_t getopt_state;
166d29b2c44Sab elfedit_getopt_ret_t *getopt_ret;
167d29b2c44Sab
168d29b2c44Sab bzero(argstate, sizeof (*argstate));
169d29b2c44Sab argstate->obj_state = obj_state;
170d29b2c44Sab
171d29b2c44Sab elfedit_getopt_init(&getopt_state, &argc, &argv);
172d29b2c44Sab /* Add each new option to the options mask */
173d29b2c44Sab while ((getopt_ret = elfedit_getopt(&getopt_state)) != NULL)
174d29b2c44Sab argstate->optmask |= getopt_ret->gor_idmask;
175d29b2c44Sab
176d29b2c44Sab /* If there may be an arbitrary amount of output, use a pager */
177d29b2c44Sab if (argc == 0)
178d29b2c44Sab elfedit_pager_init();
179d29b2c44Sab
180d29b2c44Sab /* Return the updated values of argc/argv */
181d29b2c44Sab argstate->argc = argc;
182d29b2c44Sab argstate->argv = argv;
183d29b2c44Sab }
184d29b2c44Sab
185d29b2c44Sab
186d29b2c44Sab
187d29b2c44Sab
188d29b2c44Sab
189d29b2c44Sab
190d29b2c44Sab /*
191d29b2c44Sab * Format the given magic number byte into a buffer
192d29b2c44Sab *
193d29b2c44Sab * entry:
194d29b2c44Sab * value - Value of the magic value byte given by
195d29b2c44Sab * ehdr->ei_ident[EI_MAG?]
196d29b2c44Sab */
197d29b2c44Sab static const char *
conv_magic_value(int value)198d29b2c44Sab conv_magic_value(int value)
199d29b2c44Sab {
200d29b2c44Sab /*
201d29b2c44Sab * This routine can be called twice within a single C statement,
202d29b2c44Sab * so we use alternating buffers on each call to allow this
203d29b2c44Sab * without requiring the caller to supply a buffer (the size of
204d29b2c44Sab * which they don't know).
205d29b2c44Sab */
206d29b2c44Sab static char buf1[20];
207d29b2c44Sab static char buf2[20];
208d29b2c44Sab static char *buf;
209d29b2c44Sab
210d29b2c44Sab /* Switch buffers */
211d29b2c44Sab buf = (buf == buf1) ? buf2 : buf1;
212d29b2c44Sab
213d29b2c44Sab if (isprint(value))
214d29b2c44Sab (void) snprintf(buf, sizeof (buf1),
215d29b2c44Sab MSG_ORIG(MSG_FMT_HEXNUM_QCHR), value, value);
216d29b2c44Sab else
217d29b2c44Sab (void) snprintf(buf, sizeof (buf1),
218d29b2c44Sab MSG_ORIG(MSG_FMT_HEXNUM), value);
219d29b2c44Sab return (buf);
220d29b2c44Sab }
221d29b2c44Sab
222d29b2c44Sab
223d29b2c44Sab
224d29b2c44Sab /*
225d29b2c44Sab * Print ELF header values, taking the calling command, and output style
226d29b2c44Sab * into account.
227d29b2c44Sab *
228d29b2c44Sab * entry:
229d29b2c44Sab * cmd - EHDR_CMD_T_* value giving identify of caller
230d29b2c44Sab * e_ident_ndx - Ignored unless cmd is EHDR_CMD_T_E_IDENT. In IDENT
231d29b2c44Sab * case, index of item in e_ident[] array to display, or
232d29b2c44Sab * -1 to display the entire array.
233d29b2c44Sab * autoprint - If True, output is only produced if the elfedit
234d29b2c44Sab * autoprint flag is set. If False, output is always produced.
235d29b2c44Sab * argstate - Argument state block
236d29b2c44Sab */
237d29b2c44Sab static void
print_ehdr(EHDR_CMD_T cmd,int e_ident_ndx,int autoprint,ARGSTATE * argstate)238d29b2c44Sab print_ehdr(EHDR_CMD_T cmd, int e_ident_ndx, int autoprint,
239d29b2c44Sab ARGSTATE *argstate)
240d29b2c44Sab {
241d29b2c44Sab elfedit_outstyle_t outstyle;
242d29b2c44Sab Conv_fmt_flags_t flags_fmt_flags = 0;
243d29b2c44Sab Ehdr *ehdr;
244d29b2c44Sab int c;
245d29b2c44Sab Conv_inv_buf_t inv_buf;
246d29b2c44Sab
247d29b2c44Sab if (autoprint && ((elfedit_flags() & ELFEDIT_F_AUTOPRINT) == 0))
248d29b2c44Sab return;
249d29b2c44Sab
250d29b2c44Sab /*
251d29b2c44Sab * Pick an output style. ehdr:dump is required to use the default
252d29b2c44Sab * style. The other commands use the current output style.
253d29b2c44Sab */
254d29b2c44Sab if (cmd == EHDR_CMD_T_DUMP) {
255d29b2c44Sab outstyle = ELFEDIT_OUTSTYLE_DEFAULT;
256d29b2c44Sab } else {
257d29b2c44Sab outstyle = elfedit_outstyle();
258d29b2c44Sab
259d29b2c44Sab /*
260d29b2c44Sab * When the caller specifies the simple output style,
261d29b2c44Sab * omit the brackets from around the values.
262d29b2c44Sab */
263d29b2c44Sab if (outstyle == ELFEDIT_OUTSTYLE_SIMPLE)
264d29b2c44Sab flags_fmt_flags = CONV_FMT_NOBKT;
265d29b2c44Sab
266d29b2c44Sab /*
267d29b2c44Sab * For things that show a single header item, switch
268d29b2c44Sab * from default to simple mode.
269d29b2c44Sab */
270d29b2c44Sab if ((outstyle == ELFEDIT_OUTSTYLE_DEFAULT) &&
271d29b2c44Sab ((cmd != EHDR_CMD_T_E_IDENT) || (e_ident_ndx != -1)))
272d29b2c44Sab outstyle = ELFEDIT_OUTSTYLE_SIMPLE;
273d29b2c44Sab }
274d29b2c44Sab
275d29b2c44Sab ehdr = argstate->obj_state->os_ehdr;
276d29b2c44Sab
277d29b2c44Sab /*
278d29b2c44Sab * If doing default output, use elfdump style where we
279d29b2c44Sab * show the full ELF header. In this case, the command
280d29b2c44Sab * that called us doesn't matter. This can only happen
281d29b2c44Sab * from ehdr:dump or ehdr:e_ident/
282d29b2c44Sab */
283d29b2c44Sab if (outstyle == ELFEDIT_OUTSTYLE_DEFAULT) {
284d29b2c44Sab const char *ndx, *value;
285d29b2c44Sab char ndx_buf[64], value_buf[20];
286d29b2c44Sab int i;
287d29b2c44Sab
288d29b2c44Sab if (cmd == EHDR_CMD_T_DUMP) {
289d29b2c44Sab Elf_ehdr(NULL, ehdr,
290d29b2c44Sab argstate->obj_state->os_secarr[0].sec_shdr);
291d29b2c44Sab elfedit_printf(MSG_ORIG(MSG_STR_NL));
292d29b2c44Sab }
293d29b2c44Sab
294d29b2c44Sab /*
295d29b2c44Sab * Elf_ehdr() does not display all of e_ident[], so we
296d29b2c44Sab * augment by displaying the entire array separately.
297d29b2c44Sab */
298d29b2c44Sab elfedit_printf(MSG_ORIG(MSG_STR_EIDENT_HDR));
299d29b2c44Sab
300d29b2c44Sab for (i = 0; i < EI_NIDENT; i++) {
301d29b2c44Sab ndx = value = NULL;
302d29b2c44Sab
303d29b2c44Sab switch (i) {
304d29b2c44Sab case EI_MAG0:
305d29b2c44Sab case EI_MAG1:
306d29b2c44Sab case EI_MAG2:
307d29b2c44Sab case EI_MAG3:
308d29b2c44Sab ndx = elfedit_atoconst_value_to_str(
309d29b2c44Sab ELFEDIT_CONST_EI, i, 1);
310d29b2c44Sab value = conv_magic_value(ehdr->e_ident[i]);
311d29b2c44Sab break;
312d29b2c44Sab case EI_CLASS:
313d29b2c44Sab ndx = elfedit_atoconst_value_to_str(
314d29b2c44Sab ELFEDIT_CONST_EI, EI_CLASS, 1);
315d29b2c44Sab value = conv_ehdr_class(ehdr->e_ident[EI_CLASS],
316d29b2c44Sab 0, &inv_buf);
317d29b2c44Sab break;
318d29b2c44Sab case EI_DATA:
319d29b2c44Sab ndx = elfedit_atoconst_value_to_str(
320d29b2c44Sab ELFEDIT_CONST_EI, EI_DATA, 1);
321d29b2c44Sab value = conv_ehdr_data(ehdr->e_ident[EI_DATA],
322d29b2c44Sab 0, &inv_buf);
323d29b2c44Sab break;
324d29b2c44Sab case EI_VERSION:
325d29b2c44Sab ndx = elfedit_atoconst_value_to_str(
326d29b2c44Sab ELFEDIT_CONST_EI, EI_VERSION, 1);
327d29b2c44Sab value = conv_ehdr_vers(
328d29b2c44Sab ehdr->e_ident[EI_VERSION], 0, &inv_buf);
329d29b2c44Sab break;
330d29b2c44Sab case EI_OSABI:
331d29b2c44Sab ndx = elfedit_atoconst_value_to_str(
332d29b2c44Sab ELFEDIT_CONST_EI, EI_OSABI, 1);
333d29b2c44Sab value = conv_ehdr_osabi(ehdr->e_ident[EI_OSABI],
334d29b2c44Sab 0, &inv_buf);
335d29b2c44Sab break;
336d29b2c44Sab case EI_ABIVERSION:
337d29b2c44Sab ndx = elfedit_atoconst_value_to_str(
338d29b2c44Sab ELFEDIT_CONST_EI, EI_ABIVERSION, 1);
3394f680cc6SAli Bahrami value = conv_ehdr_abivers(
3404f680cc6SAli Bahrami ehdr->e_ident[EI_OSABI],
3414f680cc6SAli Bahrami ehdr->e_ident[EI_ABIVERSION],
3424f680cc6SAli Bahrami CONV_FMT_DECIMAL, &inv_buf);
343d29b2c44Sab break;
344d29b2c44Sab default:
345d29b2c44Sab value = value_buf;
346d29b2c44Sab (void) snprintf(value_buf, sizeof (value_buf),
347d29b2c44Sab MSG_ORIG(MSG_FMT_HEXNUM), ehdr->e_ident[i]);
348d29b2c44Sab break;
349d29b2c44Sab }
350d29b2c44Sab
351d29b2c44Sab if (ndx == NULL)
352d29b2c44Sab (void) snprintf(ndx_buf, sizeof (ndx_buf),
353d29b2c44Sab MSG_ORIG(MSG_FMT_BKTINT), i);
354d29b2c44Sab else
355d29b2c44Sab (void) snprintf(ndx_buf, sizeof (ndx_buf),
356d29b2c44Sab MSG_ORIG(MSG_FMT_BKTSTR), ndx);
357d29b2c44Sab elfedit_printf(MSG_ORIG(MSG_FMT_EI_ELT),
358d29b2c44Sab ndx_buf, value);
359d29b2c44Sab }
360d29b2c44Sab return;
361d29b2c44Sab }
362d29b2c44Sab
363d29b2c44Sab
364d29b2c44Sab switch (cmd) {
365d29b2c44Sab case EHDR_CMD_T_E_IDENT:
366d29b2c44Sab {
367d29b2c44Sab int i, cnt;
368d29b2c44Sab
369d29b2c44Sab /* Show one element, or the entire thing? */
370d29b2c44Sab if (e_ident_ndx == -1) {
371d29b2c44Sab i = 0;
372d29b2c44Sab cnt = EI_NIDENT;
373d29b2c44Sab } else {
374d29b2c44Sab i = e_ident_ndx;
375d29b2c44Sab cnt = 1;
376d29b2c44Sab }
377d29b2c44Sab
378d29b2c44Sab for (; cnt-- > 0; i++) {
379d29b2c44Sab /*
380d29b2c44Sab * If using numeric style, or there is
381d29b2c44Sab * no conversion routine for this item,
382d29b2c44Sab * print a simple hex value.
383d29b2c44Sab */
384d29b2c44Sab if ((outstyle == ELFEDIT_OUTSTYLE_NUM) ||
3854f680cc6SAli Bahrami (i > EI_ABIVERSION)) {
386d29b2c44Sab elfedit_printf(
387d29b2c44Sab MSG_ORIG(MSG_FMT_HEXNUMNL),
388d29b2c44Sab ehdr->e_ident[i]);
389d29b2c44Sab continue;
390d29b2c44Sab }
391d29b2c44Sab
392d29b2c44Sab /* Handle special cases in simple mode */
393d29b2c44Sab switch (i) {
394d29b2c44Sab case EI_MAG0:
395d29b2c44Sab case EI_MAG1:
396d29b2c44Sab case EI_MAG2:
397d29b2c44Sab case EI_MAG3:
398d29b2c44Sab elfedit_printf(MSG_ORIG(MSG_FMT_STRNL),
399d29b2c44Sab conv_magic_value(ehdr->e_ident[i]));
400d29b2c44Sab continue;
401d29b2c44Sab case EI_CLASS:
402d29b2c44Sab elfedit_printf(MSG_ORIG(MSG_FMT_STRNL),
403d29b2c44Sab conv_ehdr_class(
404d29b2c44Sab ehdr->e_ident[EI_CLASS], 0,
405d29b2c44Sab &inv_buf));
406d29b2c44Sab continue;
407d29b2c44Sab case EI_DATA:
408d29b2c44Sab elfedit_printf(MSG_ORIG(MSG_FMT_STRNL),
409d29b2c44Sab conv_ehdr_data(
410d29b2c44Sab ehdr->e_ident[EI_DATA], 0,
411d29b2c44Sab &inv_buf));
412d29b2c44Sab continue;
413d29b2c44Sab case EI_VERSION:
414d29b2c44Sab elfedit_printf(MSG_ORIG(MSG_FMT_STRNL),
415d29b2c44Sab conv_ehdr_vers(
416d29b2c44Sab ehdr->e_ident[EI_VERSION], 0,
417d29b2c44Sab &inv_buf));
418d29b2c44Sab continue;
419d29b2c44Sab case EI_OSABI:
420d29b2c44Sab elfedit_printf(MSG_ORIG(MSG_FMT_STRNL),
421d29b2c44Sab conv_ehdr_osabi(
422d29b2c44Sab ehdr->e_ident[EI_OSABI], 0,
423d29b2c44Sab &inv_buf));
424d29b2c44Sab continue;
4254f680cc6SAli Bahrami case EI_ABIVERSION:
4264f680cc6SAli Bahrami elfedit_printf(MSG_ORIG(MSG_FMT_STRNL),
4274f680cc6SAli Bahrami conv_ehdr_abivers(
4284f680cc6SAli Bahrami ehdr->e_ident[EI_OSABI],
4294f680cc6SAli Bahrami ehdr->e_ident[EI_ABIVERSION],
4304f680cc6SAli Bahrami CONV_FMT_DECIMAL, &inv_buf));
4314f680cc6SAli Bahrami continue;
432d29b2c44Sab }
433d29b2c44Sab }
434d29b2c44Sab }
435d29b2c44Sab return;
436d29b2c44Sab
437d29b2c44Sab case EHDR_CMD_T_E_TYPE:
438d29b2c44Sab if (outstyle == ELFEDIT_OUTSTYLE_SIMPLE)
439d29b2c44Sab elfedit_printf(MSG_ORIG(MSG_FMT_STRNL),
4404f680cc6SAli Bahrami conv_ehdr_type(ehdr->e_ident[EI_OSABI],
4414f680cc6SAli Bahrami ehdr->e_type, 0, &inv_buf));
442d29b2c44Sab else
443d29b2c44Sab elfedit_printf(MSG_ORIG(MSG_FMT_DECNUMNL),
444d29b2c44Sab ehdr->e_type);
445d29b2c44Sab return;
446d29b2c44Sab
447d29b2c44Sab case EHDR_CMD_T_E_MACHINE:
448d29b2c44Sab if (outstyle == ELFEDIT_OUTSTYLE_SIMPLE) {
449d29b2c44Sab elfedit_printf(MSG_ORIG(MSG_FMT_STRNL),
450d29b2c44Sab conv_ehdr_mach(ehdr->e_machine, 0, &inv_buf));
451d29b2c44Sab } else {
452d29b2c44Sab elfedit_printf(MSG_ORIG(MSG_FMT_DECNUMNL),
453d29b2c44Sab EC_WORD(ehdr->e_machine));
454d29b2c44Sab }
455d29b2c44Sab return;
456d29b2c44Sab
457d29b2c44Sab case EHDR_CMD_T_E_VERSION:
458d29b2c44Sab if (outstyle == ELFEDIT_OUTSTYLE_SIMPLE)
459d29b2c44Sab elfedit_printf(MSG_ORIG(MSG_FMT_STRNL),
460d29b2c44Sab conv_ehdr_vers(ehdr->e_version, 0, &inv_buf));
461d29b2c44Sab else
462d29b2c44Sab elfedit_printf(MSG_ORIG(MSG_FMT_DECNUMNL),
463d29b2c44Sab ehdr->e_version);
464d29b2c44Sab return;
465d29b2c44Sab
466d29b2c44Sab case EHDR_CMD_T_E_ENTRY:
467d29b2c44Sab elfedit_printf(MSG_ORIG(MSG_FMT_HEXNUMNL),
468d29b2c44Sab EC_WORD(ehdr->e_entry));
469d29b2c44Sab return;
470d29b2c44Sab
471d29b2c44Sab case EHDR_CMD_T_E_PHOFF:
472d29b2c44Sab elfedit_printf(MSG_ORIG(MSG_FMT_HEXNUMNL),
473d29b2c44Sab EC_WORD(ehdr->e_phoff));
474d29b2c44Sab return;
475d29b2c44Sab
476d29b2c44Sab case EHDR_CMD_T_E_SHOFF:
477d29b2c44Sab elfedit_printf(MSG_ORIG(MSG_FMT_HEXNUMNL),
478d29b2c44Sab EC_WORD(ehdr->e_shoff));
479d29b2c44Sab return;
480d29b2c44Sab
481d29b2c44Sab case EHDR_CMD_T_E_FLAGS:
482d29b2c44Sab if (outstyle == ELFEDIT_OUTSTYLE_SIMPLE) {
483d29b2c44Sab Conv_ehdr_flags_buf_t flags_buf;
484d29b2c44Sab
485d29b2c44Sab elfedit_printf(MSG_ORIG(MSG_FMT_STRNL),
486d29b2c44Sab conv_ehdr_flags(ehdr->e_machine, ehdr->e_flags,
487d29b2c44Sab flags_fmt_flags, &flags_buf));
488d29b2c44Sab } else {
489d29b2c44Sab elfedit_printf(MSG_ORIG(MSG_FMT_HEXNUMNL),
490d29b2c44Sab ehdr->e_flags);
491d29b2c44Sab }
492d29b2c44Sab return;
493d29b2c44Sab
494d29b2c44Sab case EHDR_CMD_T_E_EHSIZE:
495d29b2c44Sab elfedit_printf(MSG_ORIG(MSG_FMT_DECNUMNL),
496d29b2c44Sab EC_WORD(ehdr->e_ehsize));
497d29b2c44Sab return;
498d29b2c44Sab
499d29b2c44Sab case EHDR_CMD_T_E_PHENTSIZE:
500d29b2c44Sab elfedit_printf(MSG_ORIG(MSG_FMT_DECNUMNL),
501d29b2c44Sab EC_WORD(ehdr->e_phentsize));
502d29b2c44Sab return;
503d29b2c44Sab
504d29b2c44Sab case EHDR_CMD_T_E_PHNUM:
505d29b2c44Sab {
506d29b2c44Sab Word num = ehdr->e_phnum;
507d29b2c44Sab
508d29b2c44Sab /*
509d29b2c44Sab * If using extended indexes, fetch the real
510d29b2c44Sab * value from shdr[0].sh_info
511d29b2c44Sab */
512d29b2c44Sab if (num == PN_XNUM)
513d29b2c44Sab num = argstate->obj_state->
514d29b2c44Sab os_secarr[0].sec_shdr->sh_info;
515d29b2c44Sab
516d29b2c44Sab elfedit_printf(MSG_ORIG(MSG_FMT_DECNUMNL),
517d29b2c44Sab EC_WORD(num));
518d29b2c44Sab }
519d29b2c44Sab return;
520d29b2c44Sab
521d29b2c44Sab case EHDR_CMD_T_E_SHENTSIZE:
522d29b2c44Sab elfedit_printf(MSG_ORIG(MSG_FMT_DECNUMNL),
523d29b2c44Sab EC_WORD(ehdr->e_shentsize));
524d29b2c44Sab return;
525d29b2c44Sab
526d29b2c44Sab case EHDR_CMD_T_E_SHNUM:
527d29b2c44Sab {
528d29b2c44Sab Word num = ehdr->e_shnum;
529d29b2c44Sab
530d29b2c44Sab /*
531d29b2c44Sab * If using extended indexes, fetch the real
532d29b2c44Sab * value from shdr[0].sh_size
533d29b2c44Sab */
534d29b2c44Sab if (num == 0)
535d29b2c44Sab num = argstate->obj_state->
536d29b2c44Sab os_secarr[0].sec_shdr->sh_size;
537d29b2c44Sab
538d29b2c44Sab elfedit_printf(MSG_ORIG(MSG_FMT_DECNUMNL),
539d29b2c44Sab EC_WORD(num));
540d29b2c44Sab }
541d29b2c44Sab return;
542d29b2c44Sab
543d29b2c44Sab case EHDR_CMD_T_E_SHSTRNDX:
544d29b2c44Sab {
545d29b2c44Sab Word num = ehdr->e_shstrndx;
546d29b2c44Sab
547d29b2c44Sab /*
548d29b2c44Sab * If using extended indexes, fetch the real
549d29b2c44Sab * value from shdr[0].sh_link
550d29b2c44Sab */
551d29b2c44Sab if (num == SHN_XINDEX)
552d29b2c44Sab num = argstate->obj_state->
553d29b2c44Sab os_secarr[0].sec_shdr->sh_link;
554d29b2c44Sab
555d29b2c44Sab elfedit_printf(MSG_ORIG(MSG_FMT_DECNUMNL),
556d29b2c44Sab EC_WORD(num));
557d29b2c44Sab }
558d29b2c44Sab return;
559d29b2c44Sab
560d29b2c44Sab case EHDR_CMD_T_EI_MAG0:
561d29b2c44Sab case EHDR_CMD_T_EI_MAG1:
562d29b2c44Sab case EHDR_CMD_T_EI_MAG2:
563d29b2c44Sab case EHDR_CMD_T_EI_MAG3:
564d29b2c44Sab /* This depends on EHDR_CMD_T_EI_MAG[0-3] being contiguous */
565d29b2c44Sab c = ehdr->e_ident[cmd - EHDR_CMD_T_EI_MAG0];
566d29b2c44Sab if (outstyle == ELFEDIT_OUTSTYLE_SIMPLE)
567d29b2c44Sab elfedit_printf(MSG_ORIG(MSG_FMT_STRNL),
568d29b2c44Sab conv_magic_value(c));
569d29b2c44Sab else
570d29b2c44Sab elfedit_printf(MSG_ORIG(MSG_FMT_HEXNUMNL), c);
571d29b2c44Sab return;
572d29b2c44Sab
573d29b2c44Sab case EHDR_CMD_T_EI_CLASS:
574d29b2c44Sab c = ehdr->e_ident[EI_CLASS];
575d29b2c44Sab if (outstyle == ELFEDIT_OUTSTYLE_SIMPLE)
576d29b2c44Sab elfedit_printf(MSG_ORIG(MSG_FMT_STRNL),
577d29b2c44Sab conv_ehdr_class(c, 0, &inv_buf));
578d29b2c44Sab else
579d29b2c44Sab elfedit_printf(MSG_ORIG(MSG_FMT_HEXNUMNL), c);
580d29b2c44Sab return;
581d29b2c44Sab
582d29b2c44Sab case EHDR_CMD_T_EI_DATA:
583d29b2c44Sab c = ehdr->e_ident[EI_DATA];
584d29b2c44Sab if (outstyle == ELFEDIT_OUTSTYLE_SIMPLE)
585d29b2c44Sab elfedit_printf(MSG_ORIG(MSG_FMT_STRNL),
586d29b2c44Sab conv_ehdr_data(c, 0, &inv_buf));
587d29b2c44Sab else
588d29b2c44Sab elfedit_printf(MSG_ORIG(MSG_FMT_HEXNUMNL), c);
589d29b2c44Sab return;
590d29b2c44Sab
591d29b2c44Sab case EHDR_CMD_T_EI_VERSION:
592d29b2c44Sab c = ehdr->e_ident[EI_VERSION];
593d29b2c44Sab if (outstyle == ELFEDIT_OUTSTYLE_SIMPLE)
594d29b2c44Sab elfedit_printf(MSG_ORIG(MSG_FMT_STRNL),
595d29b2c44Sab conv_ehdr_vers(c, 0, &inv_buf));
596d29b2c44Sab else
597d29b2c44Sab elfedit_printf(MSG_ORIG(MSG_FMT_HEXNUMNL), c);
598d29b2c44Sab return;
599d29b2c44Sab
600d29b2c44Sab case EHDR_CMD_T_EI_OSABI:
601d29b2c44Sab c = ehdr->e_ident[EI_OSABI];
602d29b2c44Sab if (outstyle == ELFEDIT_OUTSTYLE_SIMPLE) {
603d29b2c44Sab elfedit_printf(MSG_ORIG(MSG_FMT_STRNL),
604d29b2c44Sab conv_ehdr_osabi(c, 0, &inv_buf));
605d29b2c44Sab } else {
606d29b2c44Sab elfedit_printf(MSG_ORIG(MSG_FMT_HEXNUMNL),
607d29b2c44Sab EC_WORD(c));
608d29b2c44Sab }
609d29b2c44Sab return;
610d29b2c44Sab
611d29b2c44Sab case EHDR_CMD_T_EI_ABIVERSION:
6124f680cc6SAli Bahrami c = ehdr->e_ident[EI_ABIVERSION];
6134f680cc6SAli Bahrami if (outstyle == ELFEDIT_OUTSTYLE_SIMPLE) {
6144f680cc6SAli Bahrami elfedit_printf(MSG_ORIG(MSG_FMT_STRNL),
6154f680cc6SAli Bahrami conv_ehdr_abivers(ehdr->e_ident[EI_OSABI],
6164f680cc6SAli Bahrami c, CONV_FMT_DECIMAL, &inv_buf));
6174f680cc6SAli Bahrami } else {
6184f680cc6SAli Bahrami elfedit_printf(MSG_ORIG(MSG_FMT_HEXNUMNL),
6194f680cc6SAli Bahrami EC_WORD(c));
6204f680cc6SAli Bahrami }
621d29b2c44Sab return;
622d29b2c44Sab }
623d29b2c44Sab }
624d29b2c44Sab
625d29b2c44Sab
626d29b2c44Sab /*
627d29b2c44Sab * Common body for the ehdr: module commands. These commands
628d29b2c44Sab * share a large amount of common behavior, so it is convenient
629d29b2c44Sab * to centralize things and use the cmd argument to handle the
630d29b2c44Sab * small differences.
631d29b2c44Sab *
632d29b2c44Sab * entry:
633d29b2c44Sab * cmd - One of the EHDR_CMD_T_* constants listed above, specifying
634d29b2c44Sab * which command to implement.
635d29b2c44Sab * obj_state, argc, argv - Standard command arguments
636d29b2c44Sab */
637d29b2c44Sab static elfedit_cmdret_t
cmd_body(EHDR_CMD_T cmd,elfedit_obj_state_t * obj_state,int argc,const char * argv[])638d29b2c44Sab cmd_body(EHDR_CMD_T cmd, elfedit_obj_state_t *obj_state,
639d29b2c44Sab int argc, const char *argv[])
640d29b2c44Sab {
641d29b2c44Sab /*
642d29b2c44Sab * When a call comes in for ehdr:e_ident[ndx], and the
643d29b2c44Sab * specified element is one that we have a special command
644d29b2c44Sab * for, then we revector to that special command instead
645d29b2c44Sab * of using the generic ehdr:e_ident processing. This array,
646d29b2c44Sab * which is indexed by the e_ident[] index value is used
647d29b2c44Sab * to decide if that is the case. If the resulting value
648d29b2c44Sab * is EHDR_CMD_T_E_IDENT, then the generic processing is
649d29b2c44Sab * used. Otherwise, we revector to the specified command.
650d29b2c44Sab */
651d29b2c44Sab static const int e_ident_revector[16] = {
652d29b2c44Sab EHDR_CMD_T_EI_MAG0, /* 0: EI_MAG0 */
653d29b2c44Sab EHDR_CMD_T_EI_MAG1, /* 1: EI_MAG1 */
654d29b2c44Sab EHDR_CMD_T_EI_MAG2, /* 2: EI_MAG2 */
655d29b2c44Sab EHDR_CMD_T_EI_MAG3, /* 3: EI_MAG3 */
656d29b2c44Sab EHDR_CMD_T_EI_CLASS, /* 4: EI_CLASS */
657d29b2c44Sab EHDR_CMD_T_EI_DATA, /* 5: EI_DATA */
658d29b2c44Sab EHDR_CMD_T_EI_VERSION, /* 6: EI_VERSION */
659d29b2c44Sab EHDR_CMD_T_EI_OSABI, /* 7: EI_OSABI */
660d29b2c44Sab EHDR_CMD_T_EI_ABIVERSION, /* 8: EI_ABIVERSION */
661d29b2c44Sab EHDR_CMD_T_E_IDENT, /* 9: generic */
662d29b2c44Sab EHDR_CMD_T_E_IDENT, /* 10: generic */
663d29b2c44Sab EHDR_CMD_T_E_IDENT, /* 11: generic */
664d29b2c44Sab EHDR_CMD_T_E_IDENT, /* 12: generic */
665d29b2c44Sab EHDR_CMD_T_E_IDENT, /* 13: generic */
666d29b2c44Sab EHDR_CMD_T_E_IDENT, /* 14: generic */
667d29b2c44Sab EHDR_CMD_T_E_IDENT, /* 15: generic */
668d29b2c44Sab };
669d29b2c44Sab
670d29b2c44Sab
671d29b2c44Sab ARGSTATE argstate;
672d29b2c44Sab Ehdr *ehdr;
673d29b2c44Sab elfedit_cmdret_t ret = ELFEDIT_CMDRET_NONE;
674d29b2c44Sab int e_ident_ndx = -1;
675d29b2c44Sab Conv_inv_buf_t inv_buf1, inv_buf2;
676d29b2c44Sab
677d29b2c44Sab /* Process the optional arguments */
678d29b2c44Sab process_args(obj_state, argc, argv, &argstate);
679d29b2c44Sab
680d29b2c44Sab /* Check number of arguments */
681d29b2c44Sab switch (cmd) {
682d29b2c44Sab case EHDR_CMD_T_DUMP:
683d29b2c44Sab /* ehdr:dump does not accept arguments */
684d29b2c44Sab if (argstate.argc > 0)
685d29b2c44Sab elfedit_command_usage();
686d29b2c44Sab break;
687d29b2c44Sab case EHDR_CMD_T_E_IDENT:
688d29b2c44Sab /*
689d29b2c44Sab * ehdr:e_ident accepts 1 or 2 arguments, the first
690d29b2c44Sab * being the index into the array, and the second being
691d29b2c44Sab * the value. If there are arguments, then process the
692d29b2c44Sab * index, and remove it from the argument list.
693d29b2c44Sab */
694d29b2c44Sab if (argstate.argc > 0) {
695d29b2c44Sab if (argstate.argc > 2)
696d29b2c44Sab elfedit_command_usage();
697d29b2c44Sab e_ident_ndx = (int)
698d29b2c44Sab elfedit_atoconst_range(argstate.argv[0],
699d29b2c44Sab MSG_ORIG(MSG_STR_INDEX), 0, EI_NIDENT - 1,
700d29b2c44Sab ELFEDIT_CONST_EI);
701d29b2c44Sab argstate.argc--;
702d29b2c44Sab argstate.argv++;
703d29b2c44Sab
704d29b2c44Sab /*
705d29b2c44Sab * If the index is for one of the e_ident elements
706d29b2c44Sab * that we have a special command for, then switch
707d29b2c44Sab * to that command. e_ident_revector[] returns
708d29b2c44Sab * EHDR_CMD_T_E_IDENT in the cases where such a command
709d29b2c44Sab * does not exist, in which case we'll continue with the
710d29b2c44Sab * generic code.
711d29b2c44Sab */
712d29b2c44Sab cmd = e_ident_revector[e_ident_ndx];
713d29b2c44Sab }
714d29b2c44Sab break;
715d29b2c44Sab case EHDR_CMD_T_E_FLAGS:
716d29b2c44Sab /* ehdr:e_flags accepts an arbitrary number of arguments */
717d29b2c44Sab break;
718d29b2c44Sab default:
719d29b2c44Sab /* The remaining commands accept a single optional argument */
720d29b2c44Sab if (argstate.argc > 1)
721d29b2c44Sab elfedit_command_usage();
722d29b2c44Sab break;
723d29b2c44Sab }
724d29b2c44Sab
725d29b2c44Sab /* If there are no arguments, dump the ELF header and return */
726d29b2c44Sab if (argstate.argc == 0) {
727d29b2c44Sab print_ehdr(cmd, e_ident_ndx, 0, &argstate);
728d29b2c44Sab return (ELFEDIT_CMDRET_NONE);
729d29b2c44Sab }
730d29b2c44Sab
731d29b2c44Sab ehdr = obj_state->os_ehdr;
732d29b2c44Sab switch (cmd) {
733d29b2c44Sab /*
734d29b2c44Sab * EHDR_CMD_T_DUMP can't get here: It never has an
735d29b2c44Sab * argument, and is handled above.
736d29b2c44Sab */
737d29b2c44Sab
738d29b2c44Sab case EHDR_CMD_T_E_IDENT:
739d29b2c44Sab {
740d29b2c44Sab /*
741d29b2c44Sab * Only those e_ident[] elements for which we
742d29b2c44Sab * don't have a specialized command come here.
743d29b2c44Sab * The argument is a value to be set in
744d29b2c44Sab * e_ident[e_ident_ndx].
745d29b2c44Sab */
746d29b2c44Sab uchar_t value = (uchar_t)
747d29b2c44Sab elfedit_atoui_range(argstate.argv[0],
748d29b2c44Sab MSG_ORIG(MSG_STR_VALUE), 0, 255, NULL);
749d29b2c44Sab
750d29b2c44Sab if (ehdr->e_ident[e_ident_ndx] == value) {
751d29b2c44Sab elfedit_msg(ELFEDIT_MSG_DEBUG,
752d29b2c44Sab MSG_INTL(MSG_DEBUG_EI_D_X_OK),
753d29b2c44Sab e_ident_ndx, EC_WORD(value));
754d29b2c44Sab } else {
755d29b2c44Sab elfedit_msg(ELFEDIT_MSG_DEBUG,
756d29b2c44Sab MSG_INTL(MSG_DEBUG_EI_D_X_CHG),
757d29b2c44Sab e_ident_ndx, ehdr->e_ident[e_ident_ndx],
758d29b2c44Sab value);
759d29b2c44Sab ret = ELFEDIT_CMDRET_MOD;
760d29b2c44Sab ehdr->e_ident[e_ident_ndx] = value;
761d29b2c44Sab }
762d29b2c44Sab }
763d29b2c44Sab break;
764d29b2c44Sab
765d29b2c44Sab case EHDR_CMD_T_E_TYPE:
766d29b2c44Sab {
767d29b2c44Sab /* The argument gives the object type */
768d29b2c44Sab Half type = (Half) elfedit_atoconst(argstate.argv[0],
769d29b2c44Sab ELFEDIT_CONST_ET);
770d29b2c44Sab const char *name = MSG_ORIG(MSG_CMD_E_TYPE);
771d29b2c44Sab
772d29b2c44Sab if (ehdr->e_type == type) {
773d29b2c44Sab elfedit_msg(ELFEDIT_MSG_DEBUG,
774d29b2c44Sab MSG_INTL(MSG_DEBUG_E_S_OK), name,
7754f680cc6SAli Bahrami conv_ehdr_type(ehdr->e_ident[EI_OSABI],
7764f680cc6SAli Bahrami ehdr->e_type, 0, &inv_buf1));
777d29b2c44Sab } else {
778d29b2c44Sab elfedit_msg(ELFEDIT_MSG_DEBUG,
779d29b2c44Sab MSG_INTL(MSG_DEBUG_E_S_CHG), name,
7804f680cc6SAli Bahrami conv_ehdr_type(ehdr->e_ident[EI_OSABI],
7814f680cc6SAli Bahrami ehdr->e_type, 0, &inv_buf1),
7824f680cc6SAli Bahrami conv_ehdr_type(ehdr->e_ident[EI_OSABI],
7834f680cc6SAli Bahrami type, 0, &inv_buf2));
784d29b2c44Sab ret = ELFEDIT_CMDRET_MOD;
785d29b2c44Sab ehdr->e_type = type;
786d29b2c44Sab }
787d29b2c44Sab }
788d29b2c44Sab break;
789d29b2c44Sab
790d29b2c44Sab case EHDR_CMD_T_E_MACHINE:
791d29b2c44Sab {
792d29b2c44Sab /* The argument gives the machine code */
793d29b2c44Sab Half mach = (Half) elfedit_atoconst(argstate.argv[0],
794d29b2c44Sab ELFEDIT_CONST_EM);
795d29b2c44Sab const char *name = MSG_ORIG(MSG_CMD_E_MACHINE);
796d29b2c44Sab
797d29b2c44Sab if (ehdr->e_machine == mach) {
798d29b2c44Sab elfedit_msg(ELFEDIT_MSG_DEBUG,
799d29b2c44Sab MSG_INTL(MSG_DEBUG_E_S_OK), name,
800d29b2c44Sab conv_ehdr_mach(ehdr->e_machine, 0,
801d29b2c44Sab &inv_buf1));
802d29b2c44Sab } else {
803d29b2c44Sab elfedit_msg(ELFEDIT_MSG_DEBUG,
804d29b2c44Sab MSG_INTL(MSG_DEBUG_E_S_CHG), name,
805d29b2c44Sab conv_ehdr_mach(ehdr->e_machine, 0,
806d29b2c44Sab &inv_buf1),
807d29b2c44Sab conv_ehdr_mach(mach, 0, &inv_buf2));
8084f680cc6SAli Bahrami ret = ELFEDIT_CMDRET_MOD_OS_MACH;
809d29b2c44Sab ehdr->e_machine = mach;
8104f680cc6SAli Bahrami
811d29b2c44Sab }
812d29b2c44Sab }
813d29b2c44Sab break;
814d29b2c44Sab
815d29b2c44Sab case EHDR_CMD_T_E_VERSION:
816d29b2c44Sab {
817d29b2c44Sab /* The argument gives the version */
818d29b2c44Sab Word ver = (Word) elfedit_atoconst(argstate.argv[0],
819d29b2c44Sab ELFEDIT_CONST_EV);
820d29b2c44Sab const char *name = MSG_ORIG(MSG_CMD_E_VERSION);
821d29b2c44Sab
822d29b2c44Sab if (ehdr->e_version == ver) {
823d29b2c44Sab elfedit_msg(ELFEDIT_MSG_DEBUG,
824d29b2c44Sab MSG_INTL(MSG_DEBUG_E_S_OK), name,
825d29b2c44Sab conv_ehdr_vers(ehdr->e_version, 0,
826d29b2c44Sab &inv_buf1));
827d29b2c44Sab } else {
828d29b2c44Sab elfedit_msg(ELFEDIT_MSG_DEBUG,
829d29b2c44Sab MSG_INTL(MSG_DEBUG_E_S_CHG), name,
830d29b2c44Sab conv_ehdr_vers(ehdr->e_version, 0,
831d29b2c44Sab &inv_buf1),
832d29b2c44Sab conv_ehdr_vers(ver, 0, &inv_buf2));
833d29b2c44Sab ret = ELFEDIT_CMDRET_MOD;
834d29b2c44Sab ehdr->e_version = ver;
835d29b2c44Sab }
836d29b2c44Sab }
837d29b2c44Sab break;
838d29b2c44Sab
839d29b2c44Sab case EHDR_CMD_T_E_ENTRY:
840d29b2c44Sab {
841d29b2c44Sab /* The argument gives the entry address */
842d29b2c44Sab Addr entry = (Addr)
843d29b2c44Sab elfedit_atoui(argstate.argv[0], NULL);
844d29b2c44Sab const char *name = MSG_ORIG(MSG_CMD_E_ENTRY);
845d29b2c44Sab
846d29b2c44Sab if (ehdr->e_entry == entry) {
847d29b2c44Sab elfedit_msg(ELFEDIT_MSG_DEBUG,
848d29b2c44Sab MSG_INTL(MSG_DEBUG_E_LLX_OK), name,
849d29b2c44Sab EC_ADDR(ehdr->e_entry));
850d29b2c44Sab } else {
851d29b2c44Sab elfedit_msg(ELFEDIT_MSG_DEBUG,
852d29b2c44Sab MSG_INTL(MSG_DEBUG_E_LLX_CHG), name,
853d29b2c44Sab EC_ADDR(ehdr->e_entry), EC_ADDR(entry));
854d29b2c44Sab ret = ELFEDIT_CMDRET_MOD;
855d29b2c44Sab ehdr->e_entry = entry;
856d29b2c44Sab }
857d29b2c44Sab }
858d29b2c44Sab break;
859d29b2c44Sab
860d29b2c44Sab case EHDR_CMD_T_E_PHOFF:
861d29b2c44Sab {
862d29b2c44Sab /* The argument gives the program header offset */
863d29b2c44Sab Off off = (Off) elfedit_atoui(argstate.argv[0],
864d29b2c44Sab NULL);
865d29b2c44Sab const char *name = MSG_ORIG(MSG_CMD_E_PHOFF);
866d29b2c44Sab
867d29b2c44Sab if (ehdr->e_phoff == off) {
868d29b2c44Sab elfedit_msg(ELFEDIT_MSG_DEBUG,
869d29b2c44Sab MSG_INTL(MSG_DEBUG_E_LLX_OK), name,
870d29b2c44Sab EC_OFF(ehdr->e_phoff));
871d29b2c44Sab } else {
872d29b2c44Sab elfedit_msg(ELFEDIT_MSG_DEBUG,
873d29b2c44Sab MSG_INTL(MSG_DEBUG_E_LLX_CHG), name,
874d29b2c44Sab EC_OFF(ehdr->e_phoff), EC_OFF(off));
875d29b2c44Sab ret = ELFEDIT_CMDRET_MOD;
876d29b2c44Sab ehdr->e_phoff = off;
877d29b2c44Sab }
878d29b2c44Sab }
879d29b2c44Sab break;
880d29b2c44Sab
881d29b2c44Sab case EHDR_CMD_T_E_SHOFF:
882d29b2c44Sab {
883d29b2c44Sab /* The argument gives the section header offset */
884d29b2c44Sab Off off = (Off) elfedit_atoui(argstate.argv[0],
885d29b2c44Sab NULL);
886d29b2c44Sab const char *name = MSG_ORIG(MSG_CMD_E_SHOFF);
887d29b2c44Sab
888d29b2c44Sab if (ehdr->e_shoff == off) {
889d29b2c44Sab elfedit_msg(ELFEDIT_MSG_DEBUG,
890d29b2c44Sab MSG_INTL(MSG_DEBUG_E_LLX_OK), name,
891d29b2c44Sab EC_OFF(ehdr->e_shoff));
892d29b2c44Sab } else {
893d29b2c44Sab elfedit_msg(ELFEDIT_MSG_DEBUG,
894d29b2c44Sab MSG_INTL(MSG_DEBUG_E_LLX_CHG), name,
895d29b2c44Sab EC_OFF(ehdr->e_shoff), EC_OFF(off));
896d29b2c44Sab ret = ELFEDIT_CMDRET_MOD;
897d29b2c44Sab ehdr->e_shoff = off;
898d29b2c44Sab }
899d29b2c44Sab }
900d29b2c44Sab break;
901d29b2c44Sab
902d29b2c44Sab case EHDR_CMD_T_E_FLAGS:
903d29b2c44Sab {
904d29b2c44Sab Conv_ehdr_flags_buf_t flags_buf1, flags_buf2;
905d29b2c44Sab const char *name = MSG_ORIG(MSG_CMD_E_FLAGS);
906d29b2c44Sab Word flags = 0;
907d29b2c44Sab int i;
908d29b2c44Sab
909d29b2c44Sab /* Collect the arguments */
910d29b2c44Sab for (i = 0; i < argstate.argc; i++)
911d29b2c44Sab flags |= (Word)
912d29b2c44Sab elfedit_atoconst(argstate.argv[i],
913d29b2c44Sab ELFEDIT_CONST_EF);
914d29b2c44Sab
915d29b2c44Sab /* Complement the value? */
916d29b2c44Sab if (argstate.optmask & EHDR_OPT_F_CMP)
917d29b2c44Sab flags = ~flags;
918d29b2c44Sab
919d29b2c44Sab /* Perform any requested bit operations */
920d29b2c44Sab if (argstate.optmask & EHDR_OPT_F_AND)
921d29b2c44Sab flags &= ehdr->e_flags;
922d29b2c44Sab else if (argstate.optmask & EHDR_OPT_F_OR)
923d29b2c44Sab flags |= ehdr->e_flags;
924d29b2c44Sab
925d29b2c44Sab /* Set the value */
926d29b2c44Sab if (ehdr->e_flags == flags) {
927d29b2c44Sab elfedit_msg(ELFEDIT_MSG_DEBUG,
928d29b2c44Sab MSG_INTL(MSG_DEBUG_E_S_OK), name,
929d29b2c44Sab conv_ehdr_flags(ehdr->e_machine,
930d29b2c44Sab ehdr->e_flags, 0, &flags_buf1));
931d29b2c44Sab } else {
932d29b2c44Sab elfedit_msg(ELFEDIT_MSG_DEBUG,
933d29b2c44Sab MSG_INTL(MSG_DEBUG_E_S_CHG), name,
934d29b2c44Sab conv_ehdr_flags(ehdr->e_machine,
935d29b2c44Sab ehdr->e_flags, 0, &flags_buf1),
936d29b2c44Sab conv_ehdr_flags(ehdr->e_machine,
937d29b2c44Sab flags, 0, &flags_buf2));
938d29b2c44Sab ret = ELFEDIT_CMDRET_MOD;
939d29b2c44Sab ehdr->e_flags = flags;
940d29b2c44Sab }
941d29b2c44Sab }
942d29b2c44Sab break;
943d29b2c44Sab
944d29b2c44Sab case EHDR_CMD_T_E_EHSIZE:
945d29b2c44Sab {
946d29b2c44Sab /* The argument gives the ELF header size */
947d29b2c44Sab Half ehsize = (Half) elfedit_atoui(argstate.argv[0],
948d29b2c44Sab NULL);
949d29b2c44Sab const char *name = MSG_ORIG(MSG_CMD_E_EHSIZE);
950d29b2c44Sab
951d29b2c44Sab if (ehdr->e_ehsize == ehsize) {
952d29b2c44Sab elfedit_msg(ELFEDIT_MSG_DEBUG,
953d29b2c44Sab MSG_INTL(MSG_DEBUG_E_D_OK), name,
954d29b2c44Sab EC_WORD(ehdr->e_ehsize));
955d29b2c44Sab } else {
956d29b2c44Sab elfedit_msg(ELFEDIT_MSG_DEBUG,
957d29b2c44Sab MSG_INTL(MSG_DEBUG_E_D_CHG), name,
958d29b2c44Sab EC_WORD(ehdr->e_ehsize), EC_WORD(ehsize));
959d29b2c44Sab ret = ELFEDIT_CMDRET_MOD;
960d29b2c44Sab ehdr->e_ehsize = ehsize;
961d29b2c44Sab }
962d29b2c44Sab }
963d29b2c44Sab break;
964d29b2c44Sab
965d29b2c44Sab case EHDR_CMD_T_E_PHENTSIZE:
966d29b2c44Sab {
967d29b2c44Sab /*
968d29b2c44Sab * The argument gives the size of a program
969d29b2c44Sab * header element.
970d29b2c44Sab */
971d29b2c44Sab Half phentsize = (Half) elfedit_atoui(argstate.argv[0],
972d29b2c44Sab NULL);
973d29b2c44Sab const char *name = MSG_ORIG(MSG_CMD_E_PHENTSIZE);
974d29b2c44Sab
975d29b2c44Sab if (ehdr->e_phentsize == phentsize) {
976d29b2c44Sab elfedit_msg(ELFEDIT_MSG_DEBUG,
977d29b2c44Sab MSG_INTL(MSG_DEBUG_E_D_OK), name,
978d29b2c44Sab EC_WORD(ehdr->e_phentsize));
979d29b2c44Sab } else {
980d29b2c44Sab elfedit_msg(ELFEDIT_MSG_DEBUG,
981d29b2c44Sab MSG_INTL(MSG_DEBUG_E_D_CHG), name,
982d29b2c44Sab EC_WORD(ehdr->e_phentsize),
983d29b2c44Sab EC_WORD(phentsize));
984d29b2c44Sab ret = ELFEDIT_CMDRET_MOD;
985d29b2c44Sab ehdr->e_phentsize = phentsize;
986d29b2c44Sab }
987d29b2c44Sab }
988d29b2c44Sab break;
989d29b2c44Sab
990d29b2c44Sab case EHDR_CMD_T_E_PHNUM:
991d29b2c44Sab {
992d29b2c44Sab /* The argument gives the number of program headers */
993d29b2c44Sab Word phnum = (Word) elfedit_atoui(argstate.argv[0],
994d29b2c44Sab NULL);
995d29b2c44Sab const char *name = MSG_ORIG(MSG_CMD_E_PHNUM);
996d29b2c44Sab elfedit_section_t *sec0 = &obj_state->os_secarr[0];
997d29b2c44Sab Shdr *shdr0 = sec0->sec_shdr;
998d29b2c44Sab Half e_phnum;
999d29b2c44Sab Word sh_info;
1000d29b2c44Sab
1001d29b2c44Sab if (phnum >= PN_XNUM) {
1002d29b2c44Sab e_phnum = PN_XNUM;
1003d29b2c44Sab sh_info = phnum;
1004d29b2c44Sab } else {
1005d29b2c44Sab e_phnum = phnum;
1006d29b2c44Sab sh_info = 0;
1007d29b2c44Sab }
1008d29b2c44Sab
1009d29b2c44Sab if (ehdr->e_phnum == e_phnum) {
1010d29b2c44Sab elfedit_msg(ELFEDIT_MSG_DEBUG,
1011d29b2c44Sab MSG_INTL(MSG_DEBUG_E_D_OK), name,
1012d29b2c44Sab EC_WORD(ehdr->e_phnum));
1013d29b2c44Sab } else {
1014d29b2c44Sab elfedit_msg(ELFEDIT_MSG_DEBUG,
1015d29b2c44Sab MSG_INTL(MSG_DEBUG_E_D_CHG), name,
1016d29b2c44Sab EC_WORD(ehdr->e_phnum), e_phnum);
1017d29b2c44Sab ret = ELFEDIT_CMDRET_MOD;
1018d29b2c44Sab ehdr->e_phnum = e_phnum;
1019d29b2c44Sab }
1020d29b2c44Sab if (shdr0->sh_info == sh_info) {
1021d29b2c44Sab elfedit_msg(ELFEDIT_MSG_DEBUG,
1022d29b2c44Sab MSG_INTL(MSG_DEBUG_SHDR0_D_OK),
1023d29b2c44Sab MSG_ORIG(MSG_STR_SH_INFO),
1024d29b2c44Sab EC_WORD(shdr0->sh_info));
1025d29b2c44Sab } else {
1026d29b2c44Sab elfedit_msg(ELFEDIT_MSG_DEBUG,
1027d29b2c44Sab MSG_INTL(MSG_DEBUG_SHDR0_D_CHG),
1028d29b2c44Sab MSG_ORIG(MSG_STR_SH_INFO),
1029d29b2c44Sab EC_WORD(shdr0->sh_info), sh_info);
1030d29b2c44Sab ret = ELFEDIT_CMDRET_MOD;
1031d29b2c44Sab shdr0->sh_info = sh_info;
1032d29b2c44Sab elfedit_modified_shdr(sec0);
1033d29b2c44Sab }
1034d29b2c44Sab }
1035d29b2c44Sab break;
1036d29b2c44Sab
1037d29b2c44Sab case EHDR_CMD_T_E_SHENTSIZE:
1038d29b2c44Sab {
1039d29b2c44Sab /*
1040d29b2c44Sab * The argument gives the size of a program
1041d29b2c44Sab * header element.
1042d29b2c44Sab */
1043d29b2c44Sab Half shentsize = (Half) elfedit_atoui(argstate.argv[0],
1044d29b2c44Sab NULL);
1045d29b2c44Sab const char *name = MSG_ORIG(MSG_CMD_E_SHENTSIZE);
1046d29b2c44Sab
1047d29b2c44Sab if (ehdr->e_shentsize == shentsize) {
1048d29b2c44Sab elfedit_msg(ELFEDIT_MSG_DEBUG,
1049d29b2c44Sab MSG_INTL(MSG_DEBUG_E_D_OK), name,
1050d29b2c44Sab EC_WORD(ehdr->e_shentsize));
1051d29b2c44Sab } else {
1052d29b2c44Sab elfedit_msg(ELFEDIT_MSG_DEBUG,
1053d29b2c44Sab MSG_INTL(MSG_DEBUG_E_D_CHG), name,
1054d29b2c44Sab EC_WORD(ehdr->e_shentsize),
1055d29b2c44Sab EC_WORD(shentsize));
1056d29b2c44Sab ret = ELFEDIT_CMDRET_MOD;
1057d29b2c44Sab ehdr->e_shentsize = shentsize;
1058d29b2c44Sab }
1059d29b2c44Sab }
1060d29b2c44Sab break;
1061d29b2c44Sab
1062d29b2c44Sab case EHDR_CMD_T_E_SHNUM:
1063d29b2c44Sab {
1064d29b2c44Sab /* The argument gives the number of section headers */
1065d29b2c44Sab Word shnum = (Word) elfedit_atoui(argstate.argv[0],
1066d29b2c44Sab NULL);
1067d29b2c44Sab const char *name = MSG_ORIG(MSG_CMD_E_SHNUM);
1068d29b2c44Sab elfedit_section_t *sec0 = &obj_state->os_secarr[0];
1069d29b2c44Sab Shdr *shdr0 = sec0->sec_shdr;
1070d29b2c44Sab Half e_shnum;
1071d29b2c44Sab Word sh_size;
1072d29b2c44Sab
1073d29b2c44Sab if (shnum >= SHN_LORESERVE) {
1074d29b2c44Sab e_shnum = 0;
1075d29b2c44Sab sh_size = shnum;
1076d29b2c44Sab } else {
1077d29b2c44Sab e_shnum = shnum;
1078d29b2c44Sab sh_size = 0;
1079d29b2c44Sab }
1080d29b2c44Sab
1081d29b2c44Sab if (ehdr->e_shnum == e_shnum) {
1082d29b2c44Sab elfedit_msg(ELFEDIT_MSG_DEBUG,
1083d29b2c44Sab MSG_INTL(MSG_DEBUG_E_D_OK), name,
1084d29b2c44Sab EC_WORD(ehdr->e_shnum));
1085d29b2c44Sab } else {
1086d29b2c44Sab elfedit_msg(ELFEDIT_MSG_DEBUG,
1087d29b2c44Sab MSG_INTL(MSG_DEBUG_E_D_CHG), name,
1088d29b2c44Sab EC_WORD(ehdr->e_shnum), e_shnum);
1089d29b2c44Sab ret = ELFEDIT_CMDRET_MOD;
1090d29b2c44Sab ehdr->e_shnum = e_shnum;
1091d29b2c44Sab }
1092d29b2c44Sab if (shdr0->sh_size == sh_size) {
1093d29b2c44Sab elfedit_msg(ELFEDIT_MSG_DEBUG,
1094d29b2c44Sab MSG_INTL(MSG_DEBUG_SHDR0_D_OK),
1095d29b2c44Sab MSG_ORIG(MSG_STR_SH_SIZE),
1096d29b2c44Sab EC_WORD(shdr0->sh_size));
1097d29b2c44Sab } else {
1098d29b2c44Sab elfedit_msg(ELFEDIT_MSG_DEBUG,
1099d29b2c44Sab MSG_INTL(MSG_DEBUG_SHDR0_D_CHG),
1100d29b2c44Sab MSG_ORIG(MSG_STR_SH_SIZE),
1101d29b2c44Sab EC_WORD(shdr0->sh_size), sh_size);
1102d29b2c44Sab ret = ELFEDIT_CMDRET_MOD;
1103d29b2c44Sab shdr0->sh_size = sh_size;
1104d29b2c44Sab elfedit_modified_shdr(sec0);
1105d29b2c44Sab }
1106d29b2c44Sab }
1107d29b2c44Sab break;
1108d29b2c44Sab
1109d29b2c44Sab case EHDR_CMD_T_E_SHSTRNDX:
1110d29b2c44Sab {
1111d29b2c44Sab const char *name = MSG_ORIG(MSG_CMD_E_SHSTRNDX);
1112d29b2c44Sab Word shstrndx;
1113d29b2c44Sab elfedit_section_t *sec0 = &obj_state->os_secarr[0];
1114d29b2c44Sab Shdr *shdr0 = sec0->sec_shdr;
1115d29b2c44Sab Half e_shstrndx;
1116d29b2c44Sab Word sh_link;
1117d29b2c44Sab
1118d29b2c44Sab /*
1119d29b2c44Sab * By default, sec argument is name of section.
1120d29b2c44Sab * If -shndx is used, it is a numeric index, and
1121d29b2c44Sab * if -shtyp is used, it is a section type.
1122d29b2c44Sab */
1123d29b2c44Sab if (argstate.optmask & EHDR_OPT_F_SHNDX)
1124d29b2c44Sab shstrndx = elfedit_atoshndx(argstate.argv[0],
1125d29b2c44Sab obj_state->os_shnum);
1126d29b2c44Sab else if (argstate.optmask & EHDR_OPT_F_SHTYP)
1127d29b2c44Sab shstrndx = elfedit_type_to_shndx(obj_state,
1128d29b2c44Sab elfedit_atoconst(argstate.argv[0],
1129d29b2c44Sab ELFEDIT_CONST_SHT));
1130d29b2c44Sab else
1131d29b2c44Sab shstrndx = elfedit_name_to_shndx(obj_state,
1132d29b2c44Sab argstate.argv[0]);
1133d29b2c44Sab
1134d29b2c44Sab /* Warn if the section isn't a string table */
1135d29b2c44Sab if ((shstrndx >= obj_state->os_shnum) ||
1136d29b2c44Sab ((shstrndx >= SHN_LORESERVE) &&
1137d29b2c44Sab (shstrndx <= SHN_HIRESERVE)) ||
1138d29b2c44Sab (obj_state->os_secarr[shstrndx].sec_shdr->sh_type !=
1139d29b2c44Sab SHT_STRTAB))
1140d29b2c44Sab elfedit_msg(ELFEDIT_MSG_DEBUG,
1141d29b2c44Sab MSG_INTL(MSG_DEBUG_NOTSTRTAB), name,
1142d29b2c44Sab EC_WORD(shstrndx));
1143d29b2c44Sab
1144d29b2c44Sab if (shstrndx >= SHN_LORESERVE) {
1145d29b2c44Sab e_shstrndx = SHN_XINDEX;
1146d29b2c44Sab sh_link = shstrndx;
1147d29b2c44Sab } else {
1148d29b2c44Sab e_shstrndx = shstrndx;
1149d29b2c44Sab sh_link = 0;
1150d29b2c44Sab }
1151d29b2c44Sab
1152d29b2c44Sab if (ehdr->e_shstrndx == e_shstrndx) {
1153d29b2c44Sab elfedit_msg(ELFEDIT_MSG_DEBUG,
1154d29b2c44Sab MSG_INTL(MSG_DEBUG_E_D_OK), name,
1155d29b2c44Sab EC_WORD(ehdr->e_shstrndx));
1156d29b2c44Sab } else {
1157d29b2c44Sab elfedit_msg(ELFEDIT_MSG_DEBUG,
1158d29b2c44Sab MSG_INTL(MSG_DEBUG_E_D_CHG), name,
1159d29b2c44Sab EC_WORD(ehdr->e_shstrndx), e_shstrndx);
1160d29b2c44Sab ret = ELFEDIT_CMDRET_MOD;
1161d29b2c44Sab ehdr->e_shstrndx = e_shstrndx;
1162d29b2c44Sab }
1163d29b2c44Sab if (shdr0->sh_link == sh_link) {
1164d29b2c44Sab elfedit_msg(ELFEDIT_MSG_DEBUG,
1165d29b2c44Sab MSG_INTL(MSG_DEBUG_SHDR0_D_OK),
1166d29b2c44Sab MSG_ORIG(MSG_STR_SH_LINK),
1167d29b2c44Sab EC_WORD(shdr0->sh_link));
1168d29b2c44Sab } else {
1169d29b2c44Sab elfedit_msg(ELFEDIT_MSG_DEBUG,
1170d29b2c44Sab MSG_INTL(MSG_DEBUG_SHDR0_D_CHG),
1171d29b2c44Sab MSG_ORIG(MSG_STR_SH_LINK),
1172d29b2c44Sab EC_WORD(shdr0->sh_link), sh_link);
1173d29b2c44Sab ret = ELFEDIT_CMDRET_MOD;
1174d29b2c44Sab shdr0->sh_link = sh_link;
1175d29b2c44Sab elfedit_modified_shdr(sec0);
1176d29b2c44Sab }
1177d29b2c44Sab }
1178d29b2c44Sab break;
1179d29b2c44Sab
1180d29b2c44Sab case EHDR_CMD_T_EI_MAG0:
1181d29b2c44Sab case EHDR_CMD_T_EI_MAG1:
1182d29b2c44Sab case EHDR_CMD_T_EI_MAG2:
1183d29b2c44Sab case EHDR_CMD_T_EI_MAG3:
1184d29b2c44Sab {
1185d29b2c44Sab /*
1186d29b2c44Sab * This depends on EHDR_CMD_T_EI_MAG[0-3]
1187d29b2c44Sab * being contiguous
1188d29b2c44Sab */
1189d29b2c44Sab int ei_ndx = (cmd - EHDR_CMD_T_EI_MAG0) + EI_MAG0;
1190d29b2c44Sab
1191d29b2c44Sab /* The argument gives the magic number byte */
1192d29b2c44Sab int mag = (int)elfedit_atoui_range(argstate.argv[0],
1193d29b2c44Sab MSG_ORIG(MSG_STR_VALUE), 0, 255, NULL);
1194d29b2c44Sab
1195d29b2c44Sab if (ehdr->e_ident[ei_ndx] == mag) {
1196d29b2c44Sab elfedit_msg(ELFEDIT_MSG_DEBUG,
1197d29b2c44Sab MSG_INTL(MSG_DEBUG_EI_S_S_OK),
1198d29b2c44Sab elfedit_atoconst_value_to_str(
1199d29b2c44Sab ELFEDIT_CONST_EI, ei_ndx, 1),
1200d29b2c44Sab conv_magic_value(ehdr->e_ident[ei_ndx]));
1201d29b2c44Sab } else {
1202d29b2c44Sab elfedit_msg(ELFEDIT_MSG_DEBUG,
1203d29b2c44Sab MSG_INTL(MSG_DEBUG_EI_S_S_CHG),
1204d29b2c44Sab elfedit_atoconst_value_to_str(
1205d29b2c44Sab ELFEDIT_CONST_EI, ei_ndx, 1),
1206d29b2c44Sab conv_magic_value(ehdr->e_ident[ei_ndx]),
1207d29b2c44Sab conv_magic_value(mag));
1208d29b2c44Sab ret = ELFEDIT_CMDRET_MOD;
1209d29b2c44Sab ehdr->e_ident[ei_ndx] = mag;
1210d29b2c44Sab }
1211d29b2c44Sab }
1212d29b2c44Sab break;
1213d29b2c44Sab
1214d29b2c44Sab case EHDR_CMD_T_EI_CLASS:
1215d29b2c44Sab {
1216d29b2c44Sab /* The argument gives the ELFCLASS value */
1217d29b2c44Sab int class = (int)elfedit_atoconst_range(
1218d29b2c44Sab argstate.argv[0], MSG_ORIG(MSG_STR_VALUE), 0, 255,
1219d29b2c44Sab ELFEDIT_CONST_ELFCLASS);
1220d29b2c44Sab const char *name = elfedit_atoconst_value_to_str(
1221d29b2c44Sab ELFEDIT_CONST_EI, EI_CLASS, 1);
1222d29b2c44Sab
1223d29b2c44Sab if (ehdr->e_ident[EI_CLASS] == class) {
1224d29b2c44Sab elfedit_msg(ELFEDIT_MSG_DEBUG,
1225d29b2c44Sab MSG_INTL(MSG_DEBUG_EI_S_S_OK), name,
1226d29b2c44Sab conv_ehdr_class(class, 0, &inv_buf1));
1227d29b2c44Sab } else {
1228d29b2c44Sab elfedit_msg(ELFEDIT_MSG_DEBUG,
1229d29b2c44Sab MSG_INTL(MSG_DEBUG_EI_S_S_CHG), name,
1230d29b2c44Sab conv_ehdr_class(ehdr->e_ident[EI_CLASS],
1231d29b2c44Sab 0, &inv_buf1),
1232d29b2c44Sab conv_ehdr_class(class, 0, &inv_buf2));
1233d29b2c44Sab ret = ELFEDIT_CMDRET_MOD;
1234d29b2c44Sab ehdr->e_ident[EI_CLASS] = class;
1235d29b2c44Sab }
1236d29b2c44Sab }
1237d29b2c44Sab break;
1238d29b2c44Sab
1239d29b2c44Sab case EHDR_CMD_T_EI_DATA:
1240d29b2c44Sab {
1241d29b2c44Sab /* The argument gives the ELFDATA value */
1242d29b2c44Sab int data = (int)elfedit_atoconst_range(argstate.argv[0],
1243d29b2c44Sab MSG_ORIG(MSG_STR_VALUE), 0, 255,
1244d29b2c44Sab ELFEDIT_CONST_ELFDATA);
1245d29b2c44Sab const char *name = elfedit_atoconst_value_to_str(
1246d29b2c44Sab ELFEDIT_CONST_EI, EI_DATA, 1);
1247d29b2c44Sab
1248d29b2c44Sab if (ehdr->e_ident[EI_DATA] == data) {
1249d29b2c44Sab elfedit_msg(ELFEDIT_MSG_DEBUG,
1250d29b2c44Sab MSG_INTL(MSG_DEBUG_EI_S_S_OK), name,
1251d29b2c44Sab conv_ehdr_data(data, 0, &inv_buf1));
1252d29b2c44Sab } else {
1253d29b2c44Sab elfedit_msg(ELFEDIT_MSG_DEBUG,
1254d29b2c44Sab MSG_INTL(MSG_DEBUG_EI_S_S_CHG), name,
1255d29b2c44Sab conv_ehdr_data(ehdr->e_ident[EI_DATA],
1256d29b2c44Sab 0, &inv_buf1),
1257d29b2c44Sab conv_ehdr_data(data, 0, &inv_buf2));
1258d29b2c44Sab ret = ELFEDIT_CMDRET_MOD;
1259d29b2c44Sab ehdr->e_ident[EI_DATA] = data;
1260d29b2c44Sab }
1261d29b2c44Sab }
1262d29b2c44Sab break;
1263d29b2c44Sab
1264d29b2c44Sab case EHDR_CMD_T_EI_VERSION:
1265d29b2c44Sab {
1266d29b2c44Sab /* The argument gives the version */
1267d29b2c44Sab int ver = (int)elfedit_atoconst_range(argstate.argv[0],
1268d29b2c44Sab MSG_ORIG(MSG_STR_VALUE), 0, 255, ELFEDIT_CONST_EV);
1269d29b2c44Sab const char *name = elfedit_atoconst_value_to_str(
1270d29b2c44Sab ELFEDIT_CONST_EI, EI_VERSION, 1);
1271d29b2c44Sab
1272d29b2c44Sab if (ehdr->e_ident[EI_VERSION] == ver) {
1273d29b2c44Sab elfedit_msg(ELFEDIT_MSG_DEBUG,
1274d29b2c44Sab MSG_INTL(MSG_DEBUG_EI_S_S_OK), name,
1275d29b2c44Sab conv_ehdr_vers(ver, 0, &inv_buf1));
1276d29b2c44Sab } else {
1277d29b2c44Sab elfedit_msg(ELFEDIT_MSG_DEBUG,
1278d29b2c44Sab MSG_INTL(MSG_DEBUG_EI_S_S_CHG), name,
1279d29b2c44Sab conv_ehdr_vers(ehdr->e_ident[EI_VERSION],
1280d29b2c44Sab 0, &inv_buf1),
1281d29b2c44Sab conv_ehdr_vers(ver, 0, &inv_buf2));
1282d29b2c44Sab ret = ELFEDIT_CMDRET_MOD;
1283d29b2c44Sab ehdr->e_ident[EI_VERSION] = ver;
1284d29b2c44Sab }
1285d29b2c44Sab }
1286d29b2c44Sab break;
1287d29b2c44Sab
1288d29b2c44Sab case EHDR_CMD_T_EI_OSABI:
1289d29b2c44Sab {
1290d29b2c44Sab /* The argument gives the ABI code */
1291d29b2c44Sab int osabi = (int)elfedit_atoconst_range(
1292d29b2c44Sab argstate.argv[0], MSG_ORIG(MSG_STR_VALUE), 0, 255,
1293d29b2c44Sab ELFEDIT_CONST_ELFOSABI);
1294d29b2c44Sab const char *name = elfedit_atoconst_value_to_str(
1295d29b2c44Sab ELFEDIT_CONST_EI, EI_OSABI, 1);
1296d29b2c44Sab
1297d29b2c44Sab if (ehdr->e_ident[EI_OSABI] == osabi) {
1298d29b2c44Sab elfedit_msg(ELFEDIT_MSG_DEBUG,
1299d29b2c44Sab MSG_INTL(MSG_DEBUG_EI_S_S_OK), name,
1300d29b2c44Sab conv_ehdr_osabi(osabi, 0, &inv_buf1));
1301d29b2c44Sab } else {
1302d29b2c44Sab elfedit_msg(ELFEDIT_MSG_DEBUG,
1303d29b2c44Sab MSG_INTL(MSG_DEBUG_EI_S_S_CHG), name,
1304d29b2c44Sab conv_ehdr_osabi(ehdr->e_ident[EI_OSABI],
1305d29b2c44Sab 0, &inv_buf1),
1306d29b2c44Sab conv_ehdr_osabi(osabi, 0, &inv_buf2));
13074f680cc6SAli Bahrami ret = ELFEDIT_CMDRET_MOD_OS_MACH;
1308d29b2c44Sab ehdr->e_ident[EI_OSABI] = osabi;
1309d29b2c44Sab }
1310d29b2c44Sab }
1311d29b2c44Sab break;
1312d29b2c44Sab
1313d29b2c44Sab case EHDR_CMD_T_EI_ABIVERSION:
1314d29b2c44Sab {
1315d29b2c44Sab /* The argument gives the ABI version */
13164f680cc6SAli Bahrami int abiver = (int)elfedit_atoconst_range(
13174f680cc6SAli Bahrami argstate.argv[0], MSG_ORIG(MSG_STR_VALUE), 0, 255,
13184f680cc6SAli Bahrami ELFEDIT_CONST_EAV);
1319d29b2c44Sab const char *name = elfedit_atoconst_value_to_str(
1320d29b2c44Sab ELFEDIT_CONST_EI, EI_ABIVERSION, 1);
1321d29b2c44Sab
1322d29b2c44Sab if (ehdr->e_ident[EI_ABIVERSION] == abiver) {
1323d29b2c44Sab elfedit_msg(ELFEDIT_MSG_DEBUG,
13244f680cc6SAli Bahrami MSG_INTL(MSG_DEBUG_EI_S_S_OK), name,
13254f680cc6SAli Bahrami conv_ehdr_abivers(ehdr->e_ident[EI_OSABI],
13264f680cc6SAli Bahrami abiver, CONV_FMT_DECIMAL, &inv_buf1));
1327d29b2c44Sab } else {
1328d29b2c44Sab elfedit_msg(ELFEDIT_MSG_DEBUG,
13294f680cc6SAli Bahrami MSG_INTL(MSG_DEBUG_EI_S_S_CHG), name,
13304f680cc6SAli Bahrami conv_ehdr_abivers(ehdr->e_ident[EI_OSABI],
13314f680cc6SAli Bahrami ehdr->e_ident[EI_ABIVERSION],
13324f680cc6SAli Bahrami CONV_FMT_DECIMAL, &inv_buf1),
13334f680cc6SAli Bahrami conv_ehdr_abivers(ehdr->e_ident[EI_OSABI],
13344f680cc6SAli Bahrami abiver, CONV_FMT_DECIMAL, &inv_buf2));
1335d29b2c44Sab ret = ELFEDIT_CMDRET_MOD;
1336d29b2c44Sab ehdr->e_ident[EI_ABIVERSION] = abiver;
1337d29b2c44Sab }
1338d29b2c44Sab }
1339d29b2c44Sab break;
1340d29b2c44Sab }
1341d29b2c44Sab
1342d29b2c44Sab /*
1343d29b2c44Sab * If we modified the ELF header, tell libelf.
1344d29b2c44Sab */
1345d29b2c44Sab if (ret == ELFEDIT_CMDRET_MOD)
1346d29b2c44Sab elfedit_modified_ehdr(obj_state);
1347d29b2c44Sab
1348d29b2c44Sab /* Do autoprint */
1349d29b2c44Sab print_ehdr(cmd, e_ident_ndx, 1, &argstate);
1350d29b2c44Sab
1351d29b2c44Sab return (ret);
1352d29b2c44Sab }
1353d29b2c44Sab
1354d29b2c44Sab
1355d29b2c44Sab
1356d29b2c44Sab
1357d29b2c44Sab /*
1358d29b2c44Sab * Command completion functions for the various commands
1359d29b2c44Sab */
1360d29b2c44Sab
1361d29b2c44Sab /*ARGSUSED*/
1362d29b2c44Sab static void
cpl_e_ident(elfedit_obj_state_t * obj_state,void * cpldata,int argc,const char * argv[],int num_opt)1363d29b2c44Sab cpl_e_ident(elfedit_obj_state_t *obj_state, void *cpldata, int argc,
1364d29b2c44Sab const char *argv[], int num_opt)
1365d29b2c44Sab {
1366d29b2c44Sab elfedit_atoui_t ndx;
1367d29b2c44Sab
1368d29b2c44Sab /*
1369d29b2c44Sab * This command doesn't accept options, so num_opt should be
1370d29b2c44Sab * 0. This is a defensive measure, in case that should change.
1371d29b2c44Sab */
1372d29b2c44Sab argc -= num_opt;
1373d29b2c44Sab argv += num_opt;
1374d29b2c44Sab
1375d29b2c44Sab if (argc == 1) {
1376d29b2c44Sab elfedit_cpl_atoconst(cpldata, ELFEDIT_CONST_EI);
1377d29b2c44Sab return;
1378d29b2c44Sab }
1379d29b2c44Sab
1380d29b2c44Sab if (argc != 2)
1381d29b2c44Sab return;
1382d29b2c44Sab
1383d29b2c44Sab /*
1384d29b2c44Sab * In order to offer up the right completion strings for
1385d29b2c44Sab * the value, we need to know what index was given for
1386d29b2c44Sab * the first argument. If we don't recognize the index,
1387d29b2c44Sab * we want to return quietly without issuing an error,
1388d29b2c44Sab * so we use elfedit_atoui_range2(), which returns
1389d29b2c44Sab * a success/failure result and does not throw any errors.
1390d29b2c44Sab */
1391d29b2c44Sab if (elfedit_atoconst_range2(argv[0], 0, EI_NIDENT - 1,
1392d29b2c44Sab ELFEDIT_CONST_EI, &ndx) == 0)
1393d29b2c44Sab return;
1394d29b2c44Sab switch (ndx) {
1395d29b2c44Sab case EI_CLASS:
1396d29b2c44Sab elfedit_cpl_atoconst(cpldata, ELFEDIT_CONST_ELFCLASS);
1397d29b2c44Sab break;
1398d29b2c44Sab case EI_DATA:
1399d29b2c44Sab elfedit_cpl_atoconst(cpldata, ELFEDIT_CONST_ELFDATA);
1400d29b2c44Sab break;
1401d29b2c44Sab case EI_VERSION:
1402d29b2c44Sab elfedit_cpl_atoconst(cpldata, ELFEDIT_CONST_EV);
1403d29b2c44Sab break;
1404d29b2c44Sab case EI_OSABI:
1405d29b2c44Sab elfedit_cpl_atoconst(cpldata, ELFEDIT_CONST_ELFOSABI);
1406d29b2c44Sab break;
1407d29b2c44Sab }
1408d29b2c44Sab }
1409d29b2c44Sab
1410d29b2c44Sab /*ARGSUSED*/
1411d29b2c44Sab static void
cpl_e_type(elfedit_obj_state_t * obj_state,void * cpldata,int argc,const char * argv[],int num_opt)1412d29b2c44Sab cpl_e_type(elfedit_obj_state_t *obj_state, void *cpldata, int argc,
1413d29b2c44Sab const char *argv[], int num_opt)
1414d29b2c44Sab {
1415d29b2c44Sab /*
1416d29b2c44Sab * This command doesn't accept options, so num_opt should be
1417d29b2c44Sab * 0. This is a defensive measure, in case that should change.
1418d29b2c44Sab */
1419d29b2c44Sab argc -= num_opt;
1420d29b2c44Sab argv += num_opt;
1421d29b2c44Sab
1422d29b2c44Sab if (argc == 1)
1423d29b2c44Sab elfedit_cpl_atoconst(cpldata, ELFEDIT_CONST_ET);
1424d29b2c44Sab }
1425d29b2c44Sab
1426d29b2c44Sab /*ARGSUSED*/
1427d29b2c44Sab static void
cpl_e_machine(elfedit_obj_state_t * obj_state,void * cpldata,int argc,const char * argv[],int num_opt)1428d29b2c44Sab cpl_e_machine(elfedit_obj_state_t *obj_state, void *cpldata, int argc,
1429d29b2c44Sab const char *argv[], int num_opt)
1430d29b2c44Sab {
1431d29b2c44Sab /*
1432d29b2c44Sab * This command doesn't accept options, so num_opt should be
1433d29b2c44Sab * 0. This is a defensive measure, in case that should change.
1434d29b2c44Sab */
1435d29b2c44Sab argc -= num_opt;
1436d29b2c44Sab argv += num_opt;
1437d29b2c44Sab
1438d29b2c44Sab if (argc == 1)
1439d29b2c44Sab elfedit_cpl_atoconst(cpldata, ELFEDIT_CONST_EM);
1440d29b2c44Sab }
1441d29b2c44Sab
1442d29b2c44Sab /*ARGSUSED*/
1443d29b2c44Sab static void
cpl_e_version(elfedit_obj_state_t * obj_state,void * cpldata,int argc,const char * argv[],int num_opt)1444d29b2c44Sab cpl_e_version(elfedit_obj_state_t *obj_state, void *cpldata, int argc,
1445d29b2c44Sab const char *argv[], int num_opt)
1446d29b2c44Sab {
1447d29b2c44Sab /*
1448d29b2c44Sab * This command doesn't accept options, so num_opt should be
1449d29b2c44Sab * 0. This is a defensive measure, in case that should change.
1450d29b2c44Sab */
1451d29b2c44Sab argc -= num_opt;
1452d29b2c44Sab argv += num_opt;
1453d29b2c44Sab
1454d29b2c44Sab if (argc == 1)
1455d29b2c44Sab elfedit_cpl_atoconst(cpldata, ELFEDIT_CONST_EV);
1456d29b2c44Sab }
1457d29b2c44Sab
1458d29b2c44Sab /*ARGSUSED*/
1459d29b2c44Sab static void
cpl_e_flags(elfedit_obj_state_t * obj_state,void * cpldata,int argc,const char * argv[],int num_opt)1460d29b2c44Sab cpl_e_flags(elfedit_obj_state_t *obj_state, void *cpldata, int argc,
1461d29b2c44Sab const char *argv[], int num_opt)
1462d29b2c44Sab {
1463d29b2c44Sab /* This routine allows multiple flags to be specified */
1464d29b2c44Sab elfedit_cpl_atoconst(cpldata, ELFEDIT_CONST_EF);
1465d29b2c44Sab }
1466d29b2c44Sab
1467d29b2c44Sab /*ARGSUSED*/
1468d29b2c44Sab static void
cpl_e_shstrndx(elfedit_obj_state_t * obj_state,void * cpldata,int argc,const char * argv[],int num_opt)1469d29b2c44Sab cpl_e_shstrndx(elfedit_obj_state_t *obj_state, void *cpldata, int argc,
1470d29b2c44Sab const char *argv[], int num_opt)
1471d29b2c44Sab {
1472d29b2c44Sab enum { NAME, INDEX, TYPE } op;
1473d29b2c44Sab Word ndx;
1474d29b2c44Sab
1475d29b2c44Sab /*
1476d29b2c44Sab * The plainargument can be a section name, index, or
1477d29b2c44Sab * type, based on the options used. All have completions.
1478d29b2c44Sab */
1479d29b2c44Sab if (argc != (num_opt + 1))
1480d29b2c44Sab return;
1481d29b2c44Sab
1482d29b2c44Sab op = NAME;
1483d29b2c44Sab for (ndx = 0; ndx < num_opt; ndx++) {
1484d29b2c44Sab if (strcmp(argv[ndx], MSG_ORIG(MSG_STR_MINUS_SHNDX)) == 0)
1485d29b2c44Sab op = INDEX;
1486d29b2c44Sab else if (strcmp(argv[ndx], MSG_ORIG(MSG_STR_MINUS_SHTYP)) == 0)
1487d29b2c44Sab op = TYPE;
1488d29b2c44Sab }
1489d29b2c44Sab
1490d29b2c44Sab if (obj_state == NULL) { /* No object available */
1491d29b2c44Sab if (op == TYPE)
1492d29b2c44Sab elfedit_cpl_atoconst(cpldata, ELFEDIT_CONST_SHT);
1493d29b2c44Sab return;
1494d29b2c44Sab }
1495d29b2c44Sab
1496d29b2c44Sab /*
1497d29b2c44Sab * Loop over the sections and supply command completion
1498d29b2c44Sab * for the string tables in the file.
1499d29b2c44Sab */
1500d29b2c44Sab for (ndx = 0; ndx < obj_state->os_shnum; ndx++) {
1501d29b2c44Sab elfedit_section_t *sec = &obj_state->os_secarr[ndx];
1502d29b2c44Sab
1503d29b2c44Sab if (sec->sec_shdr->sh_type != SHT_STRTAB)
1504d29b2c44Sab continue;
1505d29b2c44Sab
1506d29b2c44Sab switch (op) {
1507d29b2c44Sab case NAME:
1508d29b2c44Sab elfedit_cpl_match(cpldata, sec->sec_name, 0);
1509d29b2c44Sab break;
1510d29b2c44Sab case INDEX:
151155ef6355Sab elfedit_cpl_ndx(cpldata, ndx);
1512d29b2c44Sab break;
1513d29b2c44Sab case TYPE:
1514d29b2c44Sab elfedit_cpl_atoconst(cpldata, ELFEDIT_CONST_SHT_STRTAB);
1515d29b2c44Sab break;
1516d29b2c44Sab }
1517d29b2c44Sab }
1518d29b2c44Sab }
1519d29b2c44Sab
1520d29b2c44Sab /*ARGSUSED*/
1521d29b2c44Sab static void
cpl_ei_class(elfedit_obj_state_t * obj_state,void * cpldata,int argc,const char * argv[],int num_opt)1522d29b2c44Sab cpl_ei_class(elfedit_obj_state_t *obj_state, void *cpldata, int argc,
1523d29b2c44Sab const char *argv[], int num_opt)
1524d29b2c44Sab {
1525d29b2c44Sab /*
1526d29b2c44Sab * This command doesn't accept options, so num_opt should be
1527d29b2c44Sab * 0. This is a defensive measure, in case that should change.
1528d29b2c44Sab */
1529d29b2c44Sab argc -= num_opt;
1530d29b2c44Sab argv += num_opt;
1531d29b2c44Sab
1532d29b2c44Sab if (argc == 1)
1533d29b2c44Sab elfedit_cpl_atoconst(cpldata, ELFEDIT_CONST_ELFCLASS);
1534d29b2c44Sab }
1535d29b2c44Sab
1536d29b2c44Sab /*ARGSUSED*/
1537d29b2c44Sab static void
cpl_ei_data(elfedit_obj_state_t * obj_state,void * cpldata,int argc,const char * argv[],int num_opt)1538d29b2c44Sab cpl_ei_data(elfedit_obj_state_t *obj_state, void *cpldata, int argc,
1539d29b2c44Sab const char *argv[], int num_opt)
1540d29b2c44Sab {
1541d29b2c44Sab /*
1542d29b2c44Sab * This command doesn't accept options, so num_opt should be
1543d29b2c44Sab * 0. This is a defensive measure, in case that should change.
1544d29b2c44Sab */
1545d29b2c44Sab argc -= num_opt;
1546d29b2c44Sab argv += num_opt;
1547d29b2c44Sab
1548d29b2c44Sab if (argc == 1)
1549d29b2c44Sab elfedit_cpl_atoconst(cpldata, ELFEDIT_CONST_ELFDATA);
1550d29b2c44Sab }
1551d29b2c44Sab
1552d29b2c44Sab /*ARGSUSED*/
1553d29b2c44Sab static void
cpl_ei_osabi(elfedit_obj_state_t * obj_state,void * cpldata,int argc,const char * argv[],int num_opt)1554d29b2c44Sab cpl_ei_osabi(elfedit_obj_state_t *obj_state, void *cpldata, int argc,
1555d29b2c44Sab const char *argv[], int num_opt)
1556d29b2c44Sab {
1557d29b2c44Sab /*
1558d29b2c44Sab * This command doesn't accept options, so num_opt should be
1559d29b2c44Sab * 0. This is a defensive measure, in case that should change.
1560d29b2c44Sab */
1561d29b2c44Sab argc -= num_opt;
1562d29b2c44Sab argv += num_opt;
1563d29b2c44Sab
1564d29b2c44Sab if (argc == 1)
1565d29b2c44Sab elfedit_cpl_atoconst(cpldata, ELFEDIT_CONST_ELFOSABI);
1566d29b2c44Sab }
1567d29b2c44Sab
15684f680cc6SAli Bahrami /*ARGSUSED*/
15694f680cc6SAli Bahrami static void
cpl_ei_abiversion(elfedit_obj_state_t * obj_state,void * cpldata,int argc,const char * argv[],int num_opt)15704f680cc6SAli Bahrami cpl_ei_abiversion(elfedit_obj_state_t *obj_state, void *cpldata, int argc,
15714f680cc6SAli Bahrami const char *argv[], int num_opt)
15724f680cc6SAli Bahrami {
15734f680cc6SAli Bahrami /*
15744f680cc6SAli Bahrami * This command doesn't accept options, so num_opt should be
15754f680cc6SAli Bahrami * 0. This is a defensive measure, in case that should change.
15764f680cc6SAli Bahrami */
15774f680cc6SAli Bahrami argc -= num_opt;
15784f680cc6SAli Bahrami argv += num_opt;
15794f680cc6SAli Bahrami
15804f680cc6SAli Bahrami if (argc == 1)
15814f680cc6SAli Bahrami elfedit_cpl_atoconst(cpldata, ELFEDIT_CONST_EAV);
15824f680cc6SAli Bahrami }
15834f680cc6SAli Bahrami
1584d29b2c44Sab
1585d29b2c44Sab
1586d29b2c44Sab
1587d29b2c44Sab /*
1588d29b2c44Sab * Implementation functions for the commands
1589d29b2c44Sab */
1590d29b2c44Sab static elfedit_cmdret_t
cmd_dump(elfedit_obj_state_t * obj_state,int argc,const char * argv[])1591d29b2c44Sab cmd_dump(elfedit_obj_state_t *obj_state, int argc, const char *argv[])
1592d29b2c44Sab {
1593d29b2c44Sab return (cmd_body(EHDR_CMD_T_DUMP, obj_state, argc, argv));
1594d29b2c44Sab }
1595d29b2c44Sab
1596d29b2c44Sab
1597d29b2c44Sab static elfedit_cmdret_t
cmd_e_ident(elfedit_obj_state_t * obj_state,int argc,const char * argv[])1598d29b2c44Sab cmd_e_ident(elfedit_obj_state_t *obj_state, int argc, const char *argv[])
1599d29b2c44Sab {
1600d29b2c44Sab return (cmd_body(EHDR_CMD_T_E_IDENT, obj_state, argc, argv));
1601d29b2c44Sab }
1602d29b2c44Sab
1603d29b2c44Sab
1604d29b2c44Sab static elfedit_cmdret_t
cmd_e_type(elfedit_obj_state_t * obj_state,int argc,const char * argv[])1605d29b2c44Sab cmd_e_type(elfedit_obj_state_t *obj_state, int argc, const char *argv[])
1606d29b2c44Sab {
1607d29b2c44Sab return (cmd_body(EHDR_CMD_T_E_TYPE, obj_state, argc, argv));
1608d29b2c44Sab }
1609d29b2c44Sab
1610d29b2c44Sab
1611d29b2c44Sab static elfedit_cmdret_t
cmd_e_machine(elfedit_obj_state_t * obj_state,int argc,const char * argv[])1612d29b2c44Sab cmd_e_machine(elfedit_obj_state_t *obj_state, int argc, const char *argv[])
1613d29b2c44Sab {
1614d29b2c44Sab return (cmd_body(EHDR_CMD_T_E_MACHINE, obj_state, argc, argv));
1615d29b2c44Sab }
1616d29b2c44Sab
1617d29b2c44Sab
1618d29b2c44Sab static elfedit_cmdret_t
cmd_e_version(elfedit_obj_state_t * obj_state,int argc,const char * argv[])1619d29b2c44Sab cmd_e_version(elfedit_obj_state_t *obj_state, int argc, const char *argv[])
1620d29b2c44Sab {
1621d29b2c44Sab return (cmd_body(EHDR_CMD_T_E_VERSION, obj_state, argc, argv));
1622d29b2c44Sab }
1623d29b2c44Sab
1624d29b2c44Sab
1625d29b2c44Sab static elfedit_cmdret_t
cmd_e_entry(elfedit_obj_state_t * obj_state,int argc,const char * argv[])1626d29b2c44Sab cmd_e_entry(elfedit_obj_state_t *obj_state, int argc, const char *argv[])
1627d29b2c44Sab {
1628d29b2c44Sab return (cmd_body(EHDR_CMD_T_E_ENTRY, obj_state, argc, argv));
1629d29b2c44Sab }
1630d29b2c44Sab
1631d29b2c44Sab
1632d29b2c44Sab static elfedit_cmdret_t
cmd_e_phoff(elfedit_obj_state_t * obj_state,int argc,const char * argv[])1633d29b2c44Sab cmd_e_phoff(elfedit_obj_state_t *obj_state, int argc, const char *argv[])
1634d29b2c44Sab {
1635d29b2c44Sab return (cmd_body(EHDR_CMD_T_E_PHOFF, obj_state, argc, argv));
1636d29b2c44Sab }
1637d29b2c44Sab
1638d29b2c44Sab
1639d29b2c44Sab static elfedit_cmdret_t
cmd_e_shoff(elfedit_obj_state_t * obj_state,int argc,const char * argv[])1640d29b2c44Sab cmd_e_shoff(elfedit_obj_state_t *obj_state, int argc, const char *argv[])
1641d29b2c44Sab {
1642d29b2c44Sab return (cmd_body(EHDR_CMD_T_E_SHOFF, obj_state, argc, argv));
1643d29b2c44Sab }
1644d29b2c44Sab
1645d29b2c44Sab
1646d29b2c44Sab static elfedit_cmdret_t
cmd_e_flags(elfedit_obj_state_t * obj_state,int argc,const char * argv[])1647d29b2c44Sab cmd_e_flags(elfedit_obj_state_t *obj_state, int argc, const char *argv[])
1648d29b2c44Sab {
1649d29b2c44Sab return (cmd_body(EHDR_CMD_T_E_FLAGS, obj_state, argc, argv));
1650d29b2c44Sab }
1651d29b2c44Sab
1652d29b2c44Sab
1653d29b2c44Sab static elfedit_cmdret_t
cmd_e_ehsize(elfedit_obj_state_t * obj_state,int argc,const char * argv[])1654d29b2c44Sab cmd_e_ehsize(elfedit_obj_state_t *obj_state, int argc, const char *argv[])
1655d29b2c44Sab {
1656d29b2c44Sab return (cmd_body(EHDR_CMD_T_E_EHSIZE, obj_state, argc, argv));
1657d29b2c44Sab }
1658d29b2c44Sab
1659d29b2c44Sab
1660d29b2c44Sab static elfedit_cmdret_t
cmd_e_phentsize(elfedit_obj_state_t * obj_state,int argc,const char * argv[])1661d29b2c44Sab cmd_e_phentsize(elfedit_obj_state_t *obj_state, int argc, const char *argv[])
1662d29b2c44Sab {
1663d29b2c44Sab return (cmd_body(EHDR_CMD_T_E_PHENTSIZE, obj_state, argc, argv));
1664d29b2c44Sab }
1665d29b2c44Sab
1666d29b2c44Sab
1667d29b2c44Sab static elfedit_cmdret_t
cmd_e_phnum(elfedit_obj_state_t * obj_state,int argc,const char * argv[])1668d29b2c44Sab cmd_e_phnum(elfedit_obj_state_t *obj_state, int argc, const char *argv[])
1669d29b2c44Sab {
1670d29b2c44Sab return (cmd_body(EHDR_CMD_T_E_PHNUM, obj_state, argc, argv));
1671d29b2c44Sab }
1672d29b2c44Sab
1673d29b2c44Sab
1674d29b2c44Sab static elfedit_cmdret_t
cmd_e_shentsize(elfedit_obj_state_t * obj_state,int argc,const char * argv[])1675d29b2c44Sab cmd_e_shentsize(elfedit_obj_state_t *obj_state, int argc, const char *argv[])
1676d29b2c44Sab {
1677d29b2c44Sab return (cmd_body(EHDR_CMD_T_E_SHENTSIZE, obj_state, argc, argv));
1678d29b2c44Sab }
1679d29b2c44Sab
1680d29b2c44Sab
1681d29b2c44Sab static elfedit_cmdret_t
cmd_e_shnum(elfedit_obj_state_t * obj_state,int argc,const char * argv[])1682d29b2c44Sab cmd_e_shnum(elfedit_obj_state_t *obj_state, int argc, const char *argv[])
1683d29b2c44Sab {
1684d29b2c44Sab return (cmd_body(EHDR_CMD_T_E_SHNUM, obj_state, argc, argv));
1685d29b2c44Sab }
1686d29b2c44Sab
1687d29b2c44Sab
1688d29b2c44Sab static elfedit_cmdret_t
cmd_e_shstrndx(elfedit_obj_state_t * obj_state,int argc,const char * argv[])1689d29b2c44Sab cmd_e_shstrndx(elfedit_obj_state_t *obj_state, int argc, const char *argv[])
1690d29b2c44Sab {
1691d29b2c44Sab return (cmd_body(EHDR_CMD_T_E_SHSTRNDX, obj_state, argc, argv));
1692d29b2c44Sab }
1693d29b2c44Sab
1694d29b2c44Sab
1695d29b2c44Sab static elfedit_cmdret_t
cmd_ei_mag0(elfedit_obj_state_t * obj_state,int argc,const char * argv[])1696d29b2c44Sab cmd_ei_mag0(elfedit_obj_state_t *obj_state, int argc, const char *argv[])
1697d29b2c44Sab {
1698d29b2c44Sab return (cmd_body(EHDR_CMD_T_EI_MAG0, obj_state, argc, argv));
1699d29b2c44Sab }
1700d29b2c44Sab
1701d29b2c44Sab
1702d29b2c44Sab static elfedit_cmdret_t
cmd_ei_mag1(elfedit_obj_state_t * obj_state,int argc,const char * argv[])1703d29b2c44Sab cmd_ei_mag1(elfedit_obj_state_t *obj_state, int argc, const char *argv[])
1704d29b2c44Sab {
1705d29b2c44Sab return (cmd_body(EHDR_CMD_T_EI_MAG1, obj_state, argc, argv));
1706d29b2c44Sab }
1707d29b2c44Sab
1708d29b2c44Sab
1709d29b2c44Sab static elfedit_cmdret_t
cmd_ei_mag2(elfedit_obj_state_t * obj_state,int argc,const char * argv[])1710d29b2c44Sab cmd_ei_mag2(elfedit_obj_state_t *obj_state, int argc, const char *argv[])
1711d29b2c44Sab {
1712d29b2c44Sab return (cmd_body(EHDR_CMD_T_EI_MAG2, obj_state, argc, argv));
1713d29b2c44Sab }
1714d29b2c44Sab
1715d29b2c44Sab
1716d29b2c44Sab static elfedit_cmdret_t
cmd_ei_mag3(elfedit_obj_state_t * obj_state,int argc,const char * argv[])1717d29b2c44Sab cmd_ei_mag3(elfedit_obj_state_t *obj_state, int argc, const char *argv[])
1718d29b2c44Sab {
1719d29b2c44Sab return (cmd_body(EHDR_CMD_T_EI_MAG3, obj_state, argc, argv));
1720d29b2c44Sab }
1721d29b2c44Sab
1722d29b2c44Sab
1723d29b2c44Sab static elfedit_cmdret_t
cmd_ei_class(elfedit_obj_state_t * obj_state,int argc,const char * argv[])1724d29b2c44Sab cmd_ei_class(elfedit_obj_state_t *obj_state, int argc, const char *argv[])
1725d29b2c44Sab {
1726d29b2c44Sab return (cmd_body(EHDR_CMD_T_EI_CLASS, obj_state, argc, argv));
1727d29b2c44Sab }
1728d29b2c44Sab
1729d29b2c44Sab
1730d29b2c44Sab static elfedit_cmdret_t
cmd_ei_data(elfedit_obj_state_t * obj_state,int argc,const char * argv[])1731d29b2c44Sab cmd_ei_data(elfedit_obj_state_t *obj_state, int argc, const char *argv[])
1732d29b2c44Sab {
1733d29b2c44Sab return (cmd_body(EHDR_CMD_T_EI_DATA, obj_state, argc, argv));
1734d29b2c44Sab }
1735d29b2c44Sab
1736d29b2c44Sab
1737d29b2c44Sab static elfedit_cmdret_t
cmd_ei_version(elfedit_obj_state_t * obj_state,int argc,const char * argv[])1738d29b2c44Sab cmd_ei_version(elfedit_obj_state_t *obj_state, int argc, const char *argv[])
1739d29b2c44Sab {
1740d29b2c44Sab return (cmd_body(EHDR_CMD_T_EI_VERSION, obj_state, argc, argv));
1741d29b2c44Sab }
1742d29b2c44Sab
1743d29b2c44Sab
1744d29b2c44Sab static elfedit_cmdret_t
cmd_ei_osabi(elfedit_obj_state_t * obj_state,int argc,const char * argv[])1745d29b2c44Sab cmd_ei_osabi(elfedit_obj_state_t *obj_state, int argc, const char *argv[])
1746d29b2c44Sab {
1747d29b2c44Sab return (cmd_body(EHDR_CMD_T_EI_OSABI, obj_state, argc, argv));
1748d29b2c44Sab }
1749d29b2c44Sab
1750d29b2c44Sab
1751d29b2c44Sab static elfedit_cmdret_t
cmd_ei_abiversion(elfedit_obj_state_t * obj_state,int argc,const char * argv[])1752d29b2c44Sab cmd_ei_abiversion(elfedit_obj_state_t *obj_state, int argc, const char *argv[])
1753d29b2c44Sab {
1754d29b2c44Sab return (cmd_body(EHDR_CMD_T_EI_ABIVERSION, obj_state, argc, argv));
1755d29b2c44Sab }
1756d29b2c44Sab
1757d29b2c44Sab
1758d29b2c44Sab
1759d29b2c44Sab
1760d29b2c44Sab /*ARGSUSED*/
1761d29b2c44Sab elfedit_module_t *
elfedit_init(elfedit_module_version_t version)1762d29b2c44Sab elfedit_init(elfedit_module_version_t version)
1763d29b2c44Sab {
1764d29b2c44Sab /* Many of the commands only accept -o */
1765d29b2c44Sab static elfedit_cmd_optarg_t opt_std[] = {
1766*9320f495SToomas Soome { ELFEDIT_STDOA_OPT_O, 0,
1767d29b2c44Sab ELFEDIT_CMDOA_F_INHERIT, 0, 0 },
1768d29b2c44Sab { NULL }
1769d29b2c44Sab };
1770d29b2c44Sab
1771d29b2c44Sab
1772d29b2c44Sab /* ehdr:dump */
1773d29b2c44Sab static const char *name_dump[] = {
1774d29b2c44Sab MSG_ORIG(MSG_CMD_DUMP),
1775d29b2c44Sab MSG_ORIG(MSG_STR_EMPTY), /* "" makes this the default command */
1776d29b2c44Sab NULL
1777d29b2c44Sab };
1778d29b2c44Sab
1779d29b2c44Sab /* ehdr:e_ident */
1780d29b2c44Sab static const char *name_e_ident[] = {
1781d29b2c44Sab MSG_ORIG(MSG_CMD_E_IDENT), NULL };
1782d29b2c44Sab static elfedit_cmd_optarg_t arg_e_ident[] = {
1783d29b2c44Sab { MSG_ORIG(MSG_STR_INDEX),
1784d29b2c44Sab /* MSG_INTL(MSG_ARGDESC_E_IDENT_NDX) */
1785d29b2c44Sab ELFEDIT_I18NHDL(MSG_ARGDESC_E_IDENT_NDX),
1786d29b2c44Sab ELFEDIT_CMDOA_F_OPT, 0 },
1787d29b2c44Sab { MSG_ORIG(MSG_STR_VALUE),
1788d29b2c44Sab /* MSG_INTL(MSG_ARGDESC_E_IDENT_VALUE) */
1789d29b2c44Sab ELFEDIT_I18NHDL(MSG_ARGDESC_E_IDENT_VALUE),
1790d29b2c44Sab ELFEDIT_CMDOA_F_OPT, 0 },
1791d29b2c44Sab { NULL }
1792d29b2c44Sab };
1793d29b2c44Sab
1794d29b2c44Sab /* ehdr:e_type */
1795d29b2c44Sab static const char *name_e_type[] = {
1796d29b2c44Sab MSG_ORIG(MSG_CMD_E_TYPE), NULL };
1797d29b2c44Sab static elfedit_cmd_optarg_t arg_e_type[] = {
1798d29b2c44Sab { MSG_ORIG(MSG_STR_VALUE),
1799d29b2c44Sab /* MSG_INTL(MSG_ARGDESC_E_TYPE_VALUE) */
1800d29b2c44Sab ELFEDIT_I18NHDL(MSG_ARGDESC_E_TYPE_VALUE),
1801d29b2c44Sab ELFEDIT_CMDOA_F_OPT, 0 },
1802d29b2c44Sab { NULL }
1803d29b2c44Sab };
1804d29b2c44Sab
1805d29b2c44Sab /* ehdr:e_machine */
1806d29b2c44Sab static const char *name_e_machine[] = {
1807d29b2c44Sab MSG_ORIG(MSG_CMD_E_MACHINE), NULL };
1808d29b2c44Sab static elfedit_cmd_optarg_t arg_e_machine[] = {
1809d29b2c44Sab { MSG_ORIG(MSG_STR_TYPE),
1810d29b2c44Sab /* MSG_INTL(MSG_ARGDESC_E_MACHINE_VALUE) */
1811d29b2c44Sab ELFEDIT_I18NHDL(MSG_ARGDESC_E_MACHINE_VALUE),
1812d29b2c44Sab ELFEDIT_CMDOA_F_OPT, 0 },
1813d29b2c44Sab { NULL }
1814d29b2c44Sab };
1815d29b2c44Sab
1816d29b2c44Sab /* ehdr:e_version */
1817d29b2c44Sab static const char *name_e_version[] = {
1818d29b2c44Sab MSG_ORIG(MSG_CMD_E_VERSION), NULL };
1819d29b2c44Sab static elfedit_cmd_optarg_t arg_e_version[] = {
1820d29b2c44Sab { MSG_ORIG(MSG_STR_VERSION),
1821d29b2c44Sab /* MSG_INTL(MSG_ARGDESC_E_VERSION_VALUE) */
1822d29b2c44Sab ELFEDIT_I18NHDL(MSG_ARGDESC_E_VERSION_VALUE),
1823d29b2c44Sab ELFEDIT_CMDOA_F_OPT, 0 },
1824d29b2c44Sab { NULL }
1825d29b2c44Sab };
1826d29b2c44Sab
1827d29b2c44Sab /* ehdr:e_entry */
1828d29b2c44Sab static const char *name_e_entry[] = {
1829d29b2c44Sab MSG_ORIG(MSG_CMD_E_ENTRY), NULL };
1830d29b2c44Sab static elfedit_cmd_optarg_t arg_e_entry[] = {
1831d29b2c44Sab { MSG_ORIG(MSG_STR_VALUE),
1832d29b2c44Sab /* MSG_INTL(MSG_ARGDESC_E_ENTRY_VALUE) */
1833d29b2c44Sab ELFEDIT_I18NHDL(MSG_ARGDESC_E_ENTRY_VALUE),
1834d29b2c44Sab ELFEDIT_CMDOA_F_OPT, 0 },
1835d29b2c44Sab { NULL }
1836d29b2c44Sab };
1837d29b2c44Sab
1838d29b2c44Sab /* ehdr:e_phoff */
1839d29b2c44Sab static const char *name_e_phoff[] = {
1840d29b2c44Sab MSG_ORIG(MSG_CMD_E_PHOFF), NULL };
1841d29b2c44Sab static elfedit_cmd_optarg_t arg_e_phoff[] = {
1842d29b2c44Sab { MSG_ORIG(MSG_STR_OFFSET),
1843d29b2c44Sab /* MSG_INTL(MSG_ARGDESC_E_PHOFF_VALUE) */
1844d29b2c44Sab ELFEDIT_I18NHDL(MSG_ARGDESC_E_PHOFF_VALUE),
1845d29b2c44Sab ELFEDIT_CMDOA_F_OPT, 0 },
1846d29b2c44Sab { NULL }
1847d29b2c44Sab };
1848d29b2c44Sab
1849d29b2c44Sab /* ehdr:e_shoff */
1850d29b2c44Sab static const char *name_e_shoff[] = {
1851d29b2c44Sab MSG_ORIG(MSG_CMD_E_SHOFF), NULL };
1852d29b2c44Sab static elfedit_cmd_optarg_t arg_e_shoff[] = {
1853d29b2c44Sab { MSG_ORIG(MSG_STR_OFFSET),
1854d29b2c44Sab /* MSG_INTL(MSG_ARGDESC_E_SHOFF_VALUE) */
1855d29b2c44Sab ELFEDIT_I18NHDL(MSG_ARGDESC_E_SHOFF_VALUE),
1856d29b2c44Sab ELFEDIT_CMDOA_F_OPT, 0 },
1857d29b2c44Sab { NULL }
1858d29b2c44Sab };
1859d29b2c44Sab
1860d29b2c44Sab /* ehdr:e_flags */
1861d29b2c44Sab static const char *name_e_flags[] = {
1862d29b2c44Sab MSG_ORIG(MSG_CMD_E_FLAGS), NULL };
1863d29b2c44Sab static elfedit_cmd_optarg_t opt_e_flags[] = {
1864*9320f495SToomas Soome { ELFEDIT_STDOA_OPT_AND, 0,
1865d29b2c44Sab ELFEDIT_CMDOA_F_INHERIT, EHDR_OPT_F_AND, EHDR_OPT_F_OR },
1866*9320f495SToomas Soome { ELFEDIT_STDOA_OPT_CMP, 0,
1867d29b2c44Sab ELFEDIT_CMDOA_F_INHERIT, EHDR_OPT_F_CMP, 0 },
1868*9320f495SToomas Soome { ELFEDIT_STDOA_OPT_O, 0,
1869d29b2c44Sab ELFEDIT_CMDOA_F_INHERIT, 0, 0 },
1870*9320f495SToomas Soome { ELFEDIT_STDOA_OPT_OR, 0,
1871d29b2c44Sab ELFEDIT_CMDOA_F_INHERIT, EHDR_OPT_F_OR, EHDR_OPT_F_AND },
1872d29b2c44Sab { NULL }
1873d29b2c44Sab };
1874d29b2c44Sab static elfedit_cmd_optarg_t arg_e_flags[] = {
1875d29b2c44Sab { MSG_ORIG(MSG_STR_FLAGVALUE),
1876d29b2c44Sab /* MSG_INTL(MSG_ARGDESC_E_FLAGS_VALUE) */
1877d29b2c44Sab ELFEDIT_I18NHDL(MSG_ARGDESC_E_FLAGS_VALUE),
1878d29b2c44Sab ELFEDIT_CMDOA_F_OPT | ELFEDIT_CMDOA_F_MULT, 0 },
1879d29b2c44Sab { NULL }
1880d29b2c44Sab };
1881d29b2c44Sab
1882d29b2c44Sab /* ehdr:e_ehsize */
1883d29b2c44Sab static const char *name_e_ehsize[] = {
1884d29b2c44Sab MSG_ORIG(MSG_CMD_E_EHSIZE), NULL };
1885d29b2c44Sab static elfedit_cmd_optarg_t arg_e_ehsize[] = {
1886d29b2c44Sab { MSG_ORIG(MSG_STR_VALUE),
1887d29b2c44Sab /* MSG_INTL(MSG_ARGDESC_E_EHSIZE_VALUE) */
1888d29b2c44Sab ELFEDIT_I18NHDL(MSG_ARGDESC_E_EHSIZE_VALUE),
1889d29b2c44Sab ELFEDIT_CMDOA_F_OPT, 0 },
1890d29b2c44Sab { NULL }
1891d29b2c44Sab };
1892d29b2c44Sab
1893d29b2c44Sab /* ehdr:e_phentsize */
1894d29b2c44Sab static const char *name_e_phentsize[] = {
1895d29b2c44Sab MSG_ORIG(MSG_CMD_E_PHENTSIZE), NULL };
1896d29b2c44Sab static elfedit_cmd_optarg_t arg_e_phentsize[] = {
1897d29b2c44Sab { MSG_ORIG(MSG_STR_VALUE),
1898d29b2c44Sab /* MSG_INTL(MSG_ARGDESC_E_PHENTSIZE_VALUE) */
1899d29b2c44Sab ELFEDIT_I18NHDL(MSG_ARGDESC_E_PHENTSIZE_VALUE),
1900d29b2c44Sab ELFEDIT_CMDOA_F_OPT, 0 },
1901d29b2c44Sab { NULL }
1902d29b2c44Sab };
1903d29b2c44Sab
1904d29b2c44Sab /* ehdr:e_phnum */
1905d29b2c44Sab static const char *name_e_phnum[] = {
1906d29b2c44Sab MSG_ORIG(MSG_CMD_E_PHNUM), NULL };
1907d29b2c44Sab static elfedit_cmd_optarg_t arg_e_phnum[] = {
1908d29b2c44Sab { MSG_ORIG(MSG_STR_VALUE),
1909d29b2c44Sab /* MSG_INTL(MSG_ARGDESC_E_PHNUM_VALUE) */
1910d29b2c44Sab ELFEDIT_I18NHDL(MSG_ARGDESC_E_PHNUM_VALUE),
1911d29b2c44Sab ELFEDIT_CMDOA_F_OPT, 0 },
1912d29b2c44Sab { NULL }
1913d29b2c44Sab };
1914d29b2c44Sab
1915d29b2c44Sab /* ehdr:e_shentsize */
1916d29b2c44Sab static const char *name_e_shentsize[] = {
1917d29b2c44Sab MSG_ORIG(MSG_CMD_E_SHENTSIZE), NULL };
1918d29b2c44Sab static elfedit_cmd_optarg_t arg_e_shentsize[] = {
1919d29b2c44Sab { MSG_ORIG(MSG_STR_VALUE),
1920d29b2c44Sab /* MSG_INTL(MSG_ARGDESC_E_SHENTSIZE_VALUE) */
1921d29b2c44Sab ELFEDIT_I18NHDL(MSG_ARGDESC_E_SHENTSIZE_VALUE),
1922d29b2c44Sab ELFEDIT_CMDOA_F_OPT, 0 },
1923d29b2c44Sab { NULL }
1924d29b2c44Sab };
1925d29b2c44Sab
1926d29b2c44Sab /* ehdr:e_shnum */
1927d29b2c44Sab static const char *name_e_shnum[] = {
1928d29b2c44Sab MSG_ORIG(MSG_CMD_E_SHNUM), NULL };
1929d29b2c44Sab static elfedit_cmd_optarg_t arg_e_shnum[] = {
1930d29b2c44Sab { MSG_ORIG(MSG_STR_VALUE),
1931d29b2c44Sab /* MSG_INTL(MSG_ARGDESC_E_SHNUM_VALUE) */
1932d29b2c44Sab ELFEDIT_I18NHDL(MSG_ARGDESC_E_SHNUM_VALUE),
1933d29b2c44Sab ELFEDIT_CMDOA_F_OPT, 0 },
1934d29b2c44Sab { NULL }
1935d29b2c44Sab };
1936d29b2c44Sab
1937d29b2c44Sab /* ehdr:e_shstrndx */
1938d29b2c44Sab static const char *name_e_shstrndx[] = {
1939d29b2c44Sab MSG_ORIG(MSG_CMD_E_SHSTRNDX), NULL };
1940d29b2c44Sab static elfedit_cmd_optarg_t opt_e_shstrndx[] = {
1941*9320f495SToomas Soome { ELFEDIT_STDOA_OPT_O, 0,
1942d29b2c44Sab ELFEDIT_CMDOA_F_INHERIT, 0, 0 },
1943d29b2c44Sab { MSG_ORIG(MSG_STR_MINUS_SHNDX),
1944d29b2c44Sab /* MSG_INTL(MSG_OPTDESC_SHNDX) */
1945d29b2c44Sab ELFEDIT_I18NHDL(MSG_OPTDESC_SHNDX), 0,
1946d29b2c44Sab EHDR_OPT_F_SHNDX, EHDR_OPT_F_SHTYP },
1947d29b2c44Sab { MSG_ORIG(MSG_STR_MINUS_SHTYP),
1948d29b2c44Sab /* MSG_INTL(MSG_OPTDESC_SHTYP) */
1949d29b2c44Sab ELFEDIT_I18NHDL(MSG_OPTDESC_SHTYP), 0,
1950d29b2c44Sab EHDR_OPT_F_SHTYP, EHDR_OPT_F_SHNDX, },
1951d29b2c44Sab { NULL }
1952d29b2c44Sab };
1953d29b2c44Sab static elfedit_cmd_optarg_t arg_e_shstrndx[] = {
1954d29b2c44Sab { MSG_ORIG(MSG_STR_SEC),
1955d29b2c44Sab /* MSG_INTL(MSG_ARGDESC_E_SHSTRNDX_SEC) */
1956d29b2c44Sab ELFEDIT_I18NHDL(MSG_ARGDESC_E_SHSTRNDX_SEC),
1957d29b2c44Sab ELFEDIT_CMDOA_F_OPT, 0 },
1958d29b2c44Sab { NULL }
1959d29b2c44Sab };
1960d29b2c44Sab
1961d29b2c44Sab /* ehdr:ei_mag0 */
1962d29b2c44Sab static const char *name_ei_mag0[] = {
1963d29b2c44Sab MSG_ORIG(MSG_CMD_EI_MAG0), NULL };
1964d29b2c44Sab static elfedit_cmd_optarg_t arg_ei_mag0[] = {
1965d29b2c44Sab { MSG_ORIG(MSG_STR_VALUE),
1966d29b2c44Sab /* MSG_INTL(MSG_ARGDESC_EI_MAG0_VALUE) */
1967d29b2c44Sab ELFEDIT_I18NHDL(MSG_ARGDESC_EI_MAG0_VALUE),
1968d29b2c44Sab ELFEDIT_CMDOA_F_OPT, 0 },
1969d29b2c44Sab { NULL }
1970d29b2c44Sab };
1971d29b2c44Sab
1972d29b2c44Sab /* ehdr:ei_mag1 */
1973d29b2c44Sab static const char *name_ei_mag1[] = {
1974d29b2c44Sab MSG_ORIG(MSG_CMD_EI_MAG1), NULL };
1975d29b2c44Sab static elfedit_cmd_optarg_t arg_ei_mag1[] = {
1976d29b2c44Sab { MSG_ORIG(MSG_STR_VALUE),
1977d29b2c44Sab /* MSG_INTL(MSG_ARGDESC_EI_MAG1_VALUE) */
1978d29b2c44Sab ELFEDIT_I18NHDL(MSG_ARGDESC_EI_MAG1_VALUE),
1979d29b2c44Sab ELFEDIT_CMDOA_F_OPT, 0 },
1980d29b2c44Sab { NULL }
1981d29b2c44Sab };
1982d29b2c44Sab
1983d29b2c44Sab /* ehdr:ei_mag2 */
1984d29b2c44Sab static const char *name_ei_mag2[] = {
1985d29b2c44Sab MSG_ORIG(MSG_CMD_EI_MAG2), NULL };
1986d29b2c44Sab static elfedit_cmd_optarg_t arg_ei_mag2[] = {
1987d29b2c44Sab { MSG_ORIG(MSG_STR_VALUE),
1988d29b2c44Sab /* MSG_INTL(MSG_ARGDESC_EI_MAG2_VALUE) */
1989d29b2c44Sab ELFEDIT_I18NHDL(MSG_ARGDESC_EI_MAG2_VALUE),
1990d29b2c44Sab ELFEDIT_CMDOA_F_OPT, 0 },
1991d29b2c44Sab { NULL }
1992d29b2c44Sab };
1993d29b2c44Sab
1994d29b2c44Sab /* ehdr:ei_mag3 */
1995d29b2c44Sab static const char *name_ei_mag3[] = {
1996d29b2c44Sab MSG_ORIG(MSG_CMD_EI_MAG3), NULL };
1997d29b2c44Sab static elfedit_cmd_optarg_t arg_ei_mag3[] = {
1998d29b2c44Sab { MSG_ORIG(MSG_STR_VALUE),
1999d29b2c44Sab /* MSG_INTL(MSG_ARGDESC_EI_MAG3_VALUE) */
2000d29b2c44Sab ELFEDIT_I18NHDL(MSG_ARGDESC_EI_MAG3_VALUE),
2001d29b2c44Sab ELFEDIT_CMDOA_F_OPT, 0 },
2002d29b2c44Sab { NULL }
2003d29b2c44Sab };
2004d29b2c44Sab
2005d29b2c44Sab /* ehdr:ei_class */
2006d29b2c44Sab static const char *name_ei_class[] = {
2007d29b2c44Sab MSG_ORIG(MSG_CMD_EI_CLASS), NULL };
2008d29b2c44Sab static elfedit_cmd_optarg_t arg_ei_class[] = {
2009d29b2c44Sab { MSG_ORIG(MSG_STR_VALUE),
2010d29b2c44Sab /* MSG_INTL(MSG_ARGDESC_EI_CLASS_VALUE) */
2011d29b2c44Sab ELFEDIT_I18NHDL(MSG_ARGDESC_EI_CLASS_VALUE),
2012d29b2c44Sab ELFEDIT_CMDOA_F_OPT, 0 },
2013d29b2c44Sab { NULL }
2014d29b2c44Sab };
2015d29b2c44Sab
2016d29b2c44Sab /* ehdr:ei_data */
2017d29b2c44Sab static const char *name_ei_data[] = {
2018d29b2c44Sab MSG_ORIG(MSG_CMD_EI_DATA), NULL };
2019d29b2c44Sab static elfedit_cmd_optarg_t arg_ei_data[] = {
2020d29b2c44Sab { MSG_ORIG(MSG_STR_VALUE),
2021d29b2c44Sab /* MSG_INTL(MSG_ARGDESC_EI_DATA_VALUE) */
2022d29b2c44Sab ELFEDIT_I18NHDL(MSG_ARGDESC_EI_DATA_VALUE),
2023d29b2c44Sab ELFEDIT_CMDOA_F_OPT, 0 },
2024d29b2c44Sab { NULL }
2025d29b2c44Sab };
2026d29b2c44Sab
2027d29b2c44Sab /* ehdr:ei_version */
2028d29b2c44Sab static const char *name_ei_version[] = {
2029d29b2c44Sab MSG_ORIG(MSG_CMD_EI_VERSION), NULL };
2030d29b2c44Sab /* Note: arg_e_version is also used for this command */
2031d29b2c44Sab
2032d29b2c44Sab /* ehdr:ei_osabi */
2033d29b2c44Sab static const char *name_ei_osabi[] = {
2034d29b2c44Sab MSG_ORIG(MSG_CMD_EI_OSABI), NULL };
2035d29b2c44Sab static elfedit_cmd_optarg_t arg_ei_osabi[] = {
2036d29b2c44Sab { MSG_ORIG(MSG_STR_VALUE),
2037d29b2c44Sab /* MSG_INTL(MSG_ARGDESC_EI_OSABI_VALUE) */
2038d29b2c44Sab ELFEDIT_I18NHDL(MSG_ARGDESC_EI_OSABI_VALUE),
2039d29b2c44Sab ELFEDIT_CMDOA_F_OPT, 0 },
2040d29b2c44Sab { NULL }
2041d29b2c44Sab };
2042d29b2c44Sab
2043d29b2c44Sab /* ehdr:ei_abiversion */
2044d29b2c44Sab static const char *name_ei_abiversion[] = {
2045d29b2c44Sab MSG_ORIG(MSG_CMD_EI_ABIVERSION), NULL };
2046d29b2c44Sab static elfedit_cmd_optarg_t arg_ei_abiversion[] = {
2047d29b2c44Sab { MSG_ORIG(MSG_STR_VALUE),
2048d29b2c44Sab /* MSG_INTL(MSG_ARGDESC_EI_ABIVERSION_VALUE) */
2049d29b2c44Sab ELFEDIT_I18NHDL(MSG_ARGDESC_EI_ABIVERSION_VALUE),
2050d29b2c44Sab ELFEDIT_CMDOA_F_OPT, 0 },
2051d29b2c44Sab { NULL }
2052d29b2c44Sab };
2053d29b2c44Sab
2054d29b2c44Sab
2055d29b2c44Sab
2056d29b2c44Sab
2057d29b2c44Sab static elfedit_cmd_t cmds[] = {
2058d29b2c44Sab /* ehdr:dump */
2059d29b2c44Sab { cmd_dump, NULL, name_dump,
2060d29b2c44Sab /* MSG_INTL(MSG_DESC_DUMP) */
2061d29b2c44Sab ELFEDIT_I18NHDL(MSG_DESC_DUMP),
2062d29b2c44Sab /* MSG_INTL(MSG_HELP_DUMP) */
2063d29b2c44Sab ELFEDIT_I18NHDL(MSG_HELP_DUMP),
2064d29b2c44Sab NULL, NULL },
2065d29b2c44Sab
2066d29b2c44Sab /* ehdr:e_ident */
2067d29b2c44Sab { cmd_e_ident, cpl_e_ident, name_e_ident,
2068d29b2c44Sab /* MSG_INTL(MSG_DESC_E_IDENT) */
2069d29b2c44Sab ELFEDIT_I18NHDL(MSG_DESC_E_IDENT),
2070d29b2c44Sab /* MSG_INTL(MSG_HELP_E_IDENT) */
2071d29b2c44Sab ELFEDIT_I18NHDL(MSG_HELP_E_IDENT),
2072d29b2c44Sab opt_std, arg_e_ident },
2073d29b2c44Sab
2074d29b2c44Sab /* ehdr:e_type */
2075d29b2c44Sab { cmd_e_type, cpl_e_type, name_e_type,
2076d29b2c44Sab /* MSG_INTL(MSG_DESC_E_TYPE) */
2077d29b2c44Sab ELFEDIT_I18NHDL(MSG_DESC_E_TYPE),
2078d29b2c44Sab /* MSG_INTL(MSG_HELP_E_TYPE) */
2079d29b2c44Sab ELFEDIT_I18NHDL(MSG_HELP_E_TYPE),
2080d29b2c44Sab opt_std, arg_e_type },
2081d29b2c44Sab
2082d29b2c44Sab /* ehdr:e_machine */
2083d29b2c44Sab { cmd_e_machine, cpl_e_machine, name_e_machine,
2084d29b2c44Sab /* MSG_INTL(MSG_DESC_E_MACHINE) */
2085d29b2c44Sab ELFEDIT_I18NHDL(MSG_DESC_E_MACHINE),
2086d29b2c44Sab /* MSG_INTL(MSG_HELP_E_MACHINE) */
2087d29b2c44Sab ELFEDIT_I18NHDL(MSG_HELP_E_MACHINE),
2088d29b2c44Sab opt_std, arg_e_machine },
2089d29b2c44Sab
2090d29b2c44Sab /* ehdr:e_version */
2091d29b2c44Sab { cmd_e_version, cpl_e_version, name_e_version,
2092d29b2c44Sab /* MSG_INTL(MSG_DESC_E_VERSION) */
2093d29b2c44Sab ELFEDIT_I18NHDL(MSG_DESC_E_VERSION),
2094d29b2c44Sab /* MSG_INTL(MSG_HELP_E_VERSION) */
2095d29b2c44Sab ELFEDIT_I18NHDL(MSG_HELP_E_VERSION),
2096d29b2c44Sab opt_std, arg_e_version },
2097d29b2c44Sab
2098d29b2c44Sab /* ehdr:e_entry */
2099d29b2c44Sab { cmd_e_entry, NULL, name_e_entry,
2100d29b2c44Sab /* MSG_INTL(MSG_DESC_E_ENTRY) */
2101d29b2c44Sab ELFEDIT_I18NHDL(MSG_DESC_E_ENTRY),
2102d29b2c44Sab /* MSG_INTL(MSG_HELP_E_ENTRY) */
2103d29b2c44Sab ELFEDIT_I18NHDL(MSG_HELP_E_ENTRY),
2104d29b2c44Sab opt_std, arg_e_entry },
2105d29b2c44Sab
2106d29b2c44Sab /* ehdr:e_phoff */
2107d29b2c44Sab { cmd_e_phoff, NULL, name_e_phoff,
2108d29b2c44Sab /* MSG_INTL(MSG_DESC_E_PHOFF) */
2109d29b2c44Sab ELFEDIT_I18NHDL(MSG_DESC_E_PHOFF),
2110d29b2c44Sab /* MSG_INTL(MSG_HELP_E_PHOFF) */
2111d29b2c44Sab ELFEDIT_I18NHDL(MSG_HELP_E_PHOFF),
2112d29b2c44Sab opt_std, arg_e_phoff },
2113d29b2c44Sab
2114d29b2c44Sab /* ehdr:e_shoff */
2115d29b2c44Sab { cmd_e_shoff, NULL, name_e_shoff,
2116d29b2c44Sab /* MSG_INTL(MSG_DESC_E_SHOFF) */
2117d29b2c44Sab ELFEDIT_I18NHDL(MSG_DESC_E_SHOFF),
2118d29b2c44Sab /* MSG_INTL(MSG_HELP_E_SHOFF) */
2119d29b2c44Sab ELFEDIT_I18NHDL(MSG_HELP_E_SHOFF),
2120d29b2c44Sab opt_std, arg_e_shoff },
2121d29b2c44Sab
2122d29b2c44Sab /* ehdr:e_flags */
2123d29b2c44Sab { cmd_e_flags, cpl_e_flags, name_e_flags,
2124d29b2c44Sab /* MSG_INTL(MSG_DESC_E_FLAGS) */
2125d29b2c44Sab ELFEDIT_I18NHDL(MSG_DESC_E_FLAGS),
2126d29b2c44Sab /* MSG_INTL(MSG_HELP_E_FLAGS) */
2127d29b2c44Sab ELFEDIT_I18NHDL(MSG_HELP_E_FLAGS),
2128d29b2c44Sab opt_e_flags, arg_e_flags },
2129d29b2c44Sab
2130d29b2c44Sab /* ehdr:e_ehsize */
2131d29b2c44Sab { cmd_e_ehsize, NULL, name_e_ehsize,
2132d29b2c44Sab /* MSG_INTL(MSG_DESC_E_EHSIZE) */
2133d29b2c44Sab ELFEDIT_I18NHDL(MSG_DESC_E_EHSIZE),
2134d29b2c44Sab /* MSG_INTL(MSG_HELP_E_EHSIZE) */
2135d29b2c44Sab ELFEDIT_I18NHDL(MSG_HELP_E_EHSIZE),
2136d29b2c44Sab opt_std, arg_e_ehsize },
2137d29b2c44Sab
2138d29b2c44Sab /* ehdr:e_phentsize */
2139d29b2c44Sab { cmd_e_phentsize, NULL, name_e_phentsize,
2140d29b2c44Sab /* MSG_INTL(MSG_DESC_E_PHENTSIZE) */
2141d29b2c44Sab ELFEDIT_I18NHDL(MSG_DESC_E_PHENTSIZE),
2142d29b2c44Sab /* MSG_INTL(MSG_HELP_E_PHENTSIZE) */
2143d29b2c44Sab ELFEDIT_I18NHDL(MSG_HELP_E_PHENTSIZE),
2144d29b2c44Sab opt_std, arg_e_phentsize },
2145d29b2c44Sab
2146d29b2c44Sab /* ehdr:e_phnum */
2147d29b2c44Sab { cmd_e_phnum, NULL, name_e_phnum,
2148d29b2c44Sab /* MSG_INTL(MSG_DESC_E_PHNUM) */
2149d29b2c44Sab ELFEDIT_I18NHDL(MSG_DESC_E_PHNUM),
2150d29b2c44Sab /* MSG_INTL(MSG_HELP_E_PHNUM) */
2151d29b2c44Sab ELFEDIT_I18NHDL(MSG_HELP_E_PHNUM),
2152d29b2c44Sab opt_std, arg_e_phnum },
2153d29b2c44Sab
2154d29b2c44Sab /* ehdr:e_shentsize */
2155d29b2c44Sab { cmd_e_shentsize, NULL, name_e_shentsize,
2156d29b2c44Sab /* MSG_INTL(MSG_DESC_E_SHENTSIZE) */
2157d29b2c44Sab ELFEDIT_I18NHDL(MSG_DESC_E_SHENTSIZE),
2158d29b2c44Sab /* MSG_INTL(MSG_HELP_E_SHENTSIZE) */
2159d29b2c44Sab ELFEDIT_I18NHDL(MSG_HELP_E_SHENTSIZE),
2160d29b2c44Sab opt_std, arg_e_shentsize },
2161d29b2c44Sab
2162d29b2c44Sab /* ehdr:e_shnum */
2163d29b2c44Sab { cmd_e_shnum, NULL, name_e_shnum,
2164d29b2c44Sab /* MSG_INTL(MSG_DESC_E_SHNUM) */
2165d29b2c44Sab ELFEDIT_I18NHDL(MSG_DESC_E_SHNUM),
2166d29b2c44Sab /* MSG_INTL(MSG_HELP_E_SHNUM) */
2167d29b2c44Sab ELFEDIT_I18NHDL(MSG_HELP_E_SHNUM),
2168d29b2c44Sab opt_std, arg_e_shnum },
2169d29b2c44Sab
2170d29b2c44Sab /* ehdr:e_shstrndx */
2171d29b2c44Sab { cmd_e_shstrndx, cpl_e_shstrndx, name_e_shstrndx,
2172d29b2c44Sab /* MSG_INTL(MSG_DESC_E_SHSTRNDX) */
2173d29b2c44Sab ELFEDIT_I18NHDL(MSG_DESC_E_SHSTRNDX),
2174d29b2c44Sab /* MSG_INTL(MSG_HELP_E_SHSTRNDX) */
2175d29b2c44Sab ELFEDIT_I18NHDL(MSG_HELP_E_SHSTRNDX),
2176d29b2c44Sab opt_e_shstrndx, arg_e_shstrndx },
2177d29b2c44Sab
2178d29b2c44Sab /* ehdr:ei_mag0 */
2179d29b2c44Sab { cmd_ei_mag0, NULL, name_ei_mag0,
2180d29b2c44Sab /* MSG_INTL(MSG_DESC_EI_MAG0) */
2181d29b2c44Sab ELFEDIT_I18NHDL(MSG_DESC_EI_MAG0),
2182d29b2c44Sab /* MSG_INTL(MSG_HELP_EI_MAG0) */
2183d29b2c44Sab ELFEDIT_I18NHDL(MSG_HELP_EI_MAG0),
2184d29b2c44Sab opt_std, arg_ei_mag0 },
2185d29b2c44Sab
2186d29b2c44Sab /* ehdr:ei_mag1 */
2187d29b2c44Sab { cmd_ei_mag1, NULL, name_ei_mag1,
2188d29b2c44Sab /* MSG_INTL(MSG_DESC_EI_MAG1) */
2189d29b2c44Sab ELFEDIT_I18NHDL(MSG_DESC_EI_MAG1),
2190d29b2c44Sab /* MSG_INTL(MSG_HELP_EI_MAG1) */
2191d29b2c44Sab ELFEDIT_I18NHDL(MSG_HELP_EI_MAG1),
2192d29b2c44Sab opt_std, arg_ei_mag1 },
2193d29b2c44Sab
2194d29b2c44Sab /* ehdr:ei_mag2 */
2195d29b2c44Sab { cmd_ei_mag2, NULL, name_ei_mag2,
2196d29b2c44Sab /* MSG_INTL(MSG_DESC_EI_MAG2) */
2197d29b2c44Sab ELFEDIT_I18NHDL(MSG_DESC_EI_MAG2),
2198d29b2c44Sab /* MSG_INTL(MSG_HELP_EI_MAG2) */
2199d29b2c44Sab ELFEDIT_I18NHDL(MSG_HELP_EI_MAG2),
2200d29b2c44Sab opt_std, arg_ei_mag2 },
2201d29b2c44Sab
2202d29b2c44Sab /* ehdr:ei_mag3 */
2203d29b2c44Sab { cmd_ei_mag3, NULL, name_ei_mag3,
2204d29b2c44Sab /* MSG_INTL(MSG_DESC_EI_MAG3) */
2205d29b2c44Sab ELFEDIT_I18NHDL(MSG_DESC_EI_MAG3),
2206d29b2c44Sab /* MSG_INTL(MSG_HELP_EI_MAG3) */
2207d29b2c44Sab ELFEDIT_I18NHDL(MSG_HELP_EI_MAG3),
2208d29b2c44Sab opt_std, arg_ei_mag3 },
2209d29b2c44Sab
2210d29b2c44Sab /* ehdr:ei_class */
2211d29b2c44Sab { cmd_ei_class, cpl_ei_class, name_ei_class,
2212d29b2c44Sab /* MSG_INTL(MSG_DESC_EI_CLASS) */
2213d29b2c44Sab ELFEDIT_I18NHDL(MSG_DESC_EI_CLASS),
2214d29b2c44Sab /* MSG_INTL(MSG_HELP_EI_CLASS) */
2215d29b2c44Sab ELFEDIT_I18NHDL(MSG_HELP_EI_CLASS),
2216d29b2c44Sab opt_std, arg_ei_class },
2217d29b2c44Sab
2218d29b2c44Sab /* ehdr:ei_data */
2219d29b2c44Sab { cmd_ei_data, cpl_ei_data, name_ei_data,
2220d29b2c44Sab /* MSG_INTL(MSG_DESC_EI_DATA) */
2221d29b2c44Sab ELFEDIT_I18NHDL(MSG_DESC_EI_DATA),
2222d29b2c44Sab /* MSG_INTL(MSG_HELP_EI_DATA) */
2223d29b2c44Sab ELFEDIT_I18NHDL(MSG_HELP_EI_DATA),
2224d29b2c44Sab opt_std, arg_ei_data },
2225d29b2c44Sab
2226d29b2c44Sab /* ehdr:ei_version */
2227d29b2c44Sab { cmd_ei_version, cpl_e_version, name_ei_version,
2228d29b2c44Sab /* MSG_INTL(MSG_DESC_EI_VERSION) */
2229d29b2c44Sab ELFEDIT_I18NHDL(MSG_DESC_EI_VERSION),
2230d29b2c44Sab /* MSG_INTL(MSG_HELP_EI_VERSION) */
2231d29b2c44Sab ELFEDIT_I18NHDL(MSG_HELP_EI_VERSION),
2232d29b2c44Sab opt_std, arg_e_version },
2233d29b2c44Sab
2234d29b2c44Sab /* ehdr:ei_osabi */
2235d29b2c44Sab { cmd_ei_osabi, cpl_ei_osabi, name_ei_osabi,
2236d29b2c44Sab /* MSG_INTL(MSG_DESC_EI_OSABI) */
2237d29b2c44Sab ELFEDIT_I18NHDL(MSG_DESC_EI_OSABI),
2238d29b2c44Sab /* MSG_INTL(MSG_HELP_EI_OSABI) */
2239d29b2c44Sab ELFEDIT_I18NHDL(MSG_HELP_EI_OSABI),
2240d29b2c44Sab opt_std, arg_ei_osabi },
2241d29b2c44Sab
2242d29b2c44Sab /* ehdr:ei_abiversion */
22434f680cc6SAli Bahrami { cmd_ei_abiversion, cpl_ei_abiversion, name_ei_abiversion,
2244d29b2c44Sab /* MSG_INTL(MSG_DESC_EI_ABIVERSION) */
2245d29b2c44Sab ELFEDIT_I18NHDL(MSG_DESC_EI_ABIVERSION),
2246d29b2c44Sab /* MSG_INTL(MSG_HELP_EI_ABIVERSION) */
2247d29b2c44Sab ELFEDIT_I18NHDL(MSG_HELP_EI_ABIVERSION),
2248d29b2c44Sab opt_std, arg_ei_abiversion },
2249d29b2c44Sab
2250d29b2c44Sab { NULL }
2251d29b2c44Sab };
2252d29b2c44Sab
2253d29b2c44Sab static elfedit_module_t module = {
2254d29b2c44Sab ELFEDIT_VER_CURRENT, MSG_ORIG(MSG_MOD_NAME),
2255d29b2c44Sab /* MSG_INTL(MSG_MOD_DESC) */
2256d29b2c44Sab ELFEDIT_I18NHDL(MSG_MOD_DESC),
2257d29b2c44Sab cmds, mod_i18nhdl_to_str };
2258d29b2c44Sab
2259d29b2c44Sab return (&module);
2260d29b2c44Sab }
2261