1*5088Sab196087 /* 2*5088Sab196087 * CDDL HEADER START 3*5088Sab196087 * 4*5088Sab196087 * The contents of this file are subject to the terms of the 5*5088Sab196087 * Common Development and Distribution License (the "License"). 6*5088Sab196087 * You may not use this file except in compliance with the License. 7*5088Sab196087 * 8*5088Sab196087 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*5088Sab196087 * or http://www.opensolaris.org/os/licensing. 10*5088Sab196087 * See the License for the specific language governing permissions 11*5088Sab196087 * and limitations under the License. 12*5088Sab196087 * 13*5088Sab196087 * When distributing Covered Code, include this CDDL HEADER in each 14*5088Sab196087 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*5088Sab196087 * If applicable, add the following below this CDDL HEADER, with the 16*5088Sab196087 * fields enclosed by brackets "[]" replaced with your own identifying 17*5088Sab196087 * information: Portions Copyright [yyyy] [name of copyright owner] 18*5088Sab196087 * 19*5088Sab196087 * CDDL HEADER END 20*5088Sab196087 */ 21*5088Sab196087 22*5088Sab196087 /* 23*5088Sab196087 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 24*5088Sab196087 * Use is subject to license terms. 25*5088Sab196087 */ 26*5088Sab196087 #pragma ident "%Z%%M% %I% %E% SMI" 27*5088Sab196087 28*5088Sab196087 #include <stdio.h> 29*5088Sab196087 #include <unistd.h> 30*5088Sab196087 #include <machdep.h> 31*5088Sab196087 #include <elfedit.h> 32*5088Sab196087 #include <sys/elf_SPARC.h> 33*5088Sab196087 #include <sys/elf_amd64.h> 34*5088Sab196087 #include <strings.h> 35*5088Sab196087 #include <debug.h> 36*5088Sab196087 #include <conv.h> 37*5088Sab196087 #include <shdr_msg.h> 38*5088Sab196087 39*5088Sab196087 40*5088Sab196087 41*5088Sab196087 42*5088Sab196087 /* 43*5088Sab196087 * This module uses shared code for several of the commands. 44*5088Sab196087 * It is sometimes necessary to know which specific command 45*5088Sab196087 * is active. 46*5088Sab196087 */ 47*5088Sab196087 typedef enum { 48*5088Sab196087 SHDR_CMD_T_DUMP = 0, /* shdr:dump */ 49*5088Sab196087 50*5088Sab196087 SHDR_CMD_T_SH_ADDR = 1, /* shdr:sh_addr */ 51*5088Sab196087 SHDR_CMD_T_SH_ADDRALIGN = 2, /* shdr:sh_addralign */ 52*5088Sab196087 SHDR_CMD_T_SH_ENTSIZE = 3, /* shdr:sh_entsize */ 53*5088Sab196087 SHDR_CMD_T_SH_FLAGS = 4, /* shdr:sh_flags */ 54*5088Sab196087 SHDR_CMD_T_SH_INFO = 5, /* shdr:sh_info */ 55*5088Sab196087 SHDR_CMD_T_SH_LINK = 6, /* shdr:sh_link */ 56*5088Sab196087 SHDR_CMD_T_SH_NAME = 7, /* shdr:sh_name */ 57*5088Sab196087 SHDR_CMD_T_SH_OFFSET = 8, /* shdr:sh_offset */ 58*5088Sab196087 SHDR_CMD_T_SH_SIZE = 9, /* shdr:sh_size */ 59*5088Sab196087 SHDR_CMD_T_SH_TYPE = 10 /* shdr:sh_type */ 60*5088Sab196087 } SHDR_CMD_T; 61*5088Sab196087 62*5088Sab196087 63*5088Sab196087 64*5088Sab196087 #ifndef _ELF64 65*5088Sab196087 /* 66*5088Sab196087 * We supply this function for the msg module. Only one copy is needed. 67*5088Sab196087 */ 68*5088Sab196087 const char * 69*5088Sab196087 _shdr_msg(Msg mid) 70*5088Sab196087 { 71*5088Sab196087 return (gettext(MSG_ORIG(mid))); 72*5088Sab196087 } 73*5088Sab196087 74*5088Sab196087 #endif 75*5088Sab196087 76*5088Sab196087 77*5088Sab196087 78*5088Sab196087 /* 79*5088Sab196087 * This function is supplied to elfedit through our elfedit_module_t 80*5088Sab196087 * definition. It translates the opaque elfedit_i18nhdl_t handles 81*5088Sab196087 * in our module interface into the actual strings for elfedit to 82*5088Sab196087 * use. 83*5088Sab196087 * 84*5088Sab196087 * note: 85*5088Sab196087 * This module uses Msg codes for its i18n handle type. 86*5088Sab196087 * So the translation is simply to use MSG_INTL() to turn 87*5088Sab196087 * it into a string and return it. 88*5088Sab196087 */ 89*5088Sab196087 static const char * 90*5088Sab196087 mod_i18nhdl_to_str(elfedit_i18nhdl_t hdl) 91*5088Sab196087 { 92*5088Sab196087 Msg msg = (Msg)hdl; 93*5088Sab196087 94*5088Sab196087 return (MSG_INTL(msg)); 95*5088Sab196087 } 96*5088Sab196087 97*5088Sab196087 98*5088Sab196087 99*5088Sab196087 /* 100*5088Sab196087 * The shdr_opt_t enum specifies a bit value for every optional 101*5088Sab196087 * argument allowed by a command in this module. 102*5088Sab196087 */ 103*5088Sab196087 typedef enum { 104*5088Sab196087 SHDR_OPT_F_AND = 1, /* -and: AND (&) values to dest */ 105*5088Sab196087 SHDR_OPT_F_CMP = 2, /* -cmp: Complement (~) values */ 106*5088Sab196087 SHDR_OPT_F_NAMOFFSET = 4, /* -name_offset: Name arg is numeric */ 107*5088Sab196087 /* ofset rather than string */ 108*5088Sab196087 SHDR_OPT_F_OR = 8, /* -or: OR (|) values to dest */ 109*5088Sab196087 SHDR_OPT_F_SHNDX = 16, /* -shndx: Section by index, not name */ 110*5088Sab196087 SHDR_OPT_F_SHTYP = 32 /* -shtyp: Section by type, not name */ 111*5088Sab196087 } shdr_opt_t; 112*5088Sab196087 113*5088Sab196087 114*5088Sab196087 /* 115*5088Sab196087 * A variable of type ARGSTATE is used by each command to maintain 116*5088Sab196087 * information about the section headers and related things. It is 117*5088Sab196087 * initialized by process_args(), and used by the other routines. 118*5088Sab196087 */ 119*5088Sab196087 typedef struct { 120*5088Sab196087 elfedit_obj_state_t *obj_state; 121*5088Sab196087 shdr_opt_t optmask; /* Mask of options used */ 122*5088Sab196087 int argc; /* # of plain arguments */ 123*5088Sab196087 const char **argv; /* Plain arguments */ 124*5088Sab196087 } ARGSTATE; 125*5088Sab196087 126*5088Sab196087 127*5088Sab196087 128*5088Sab196087 129*5088Sab196087 /* 130*5088Sab196087 * Standard argument processing for shdr module 131*5088Sab196087 * 132*5088Sab196087 * entry 133*5088Sab196087 * obj_state, argc, argv - Standard command arguments 134*5088Sab196087 * optmask - Mask of allowed optional arguments. 135*5088Sab196087 * cmd - SHDR_CMD_T_* value giving identify of caller 136*5088Sab196087 * argstate - Address of ARGSTATE block to be initialized 137*5088Sab196087 * 138*5088Sab196087 * exit: 139*5088Sab196087 * On success, *argstate is initialized. On error, 140*5088Sab196087 * an error is issued and this routine does not return. 141*5088Sab196087 */ 142*5088Sab196087 static void 143*5088Sab196087 process_args(elfedit_obj_state_t *obj_state, int argc, const char *argv[], 144*5088Sab196087 SHDR_CMD_T cmd, ARGSTATE *argstate) 145*5088Sab196087 { 146*5088Sab196087 elfedit_getopt_state_t getopt_state; 147*5088Sab196087 elfedit_getopt_ret_t *getopt_ret; 148*5088Sab196087 149*5088Sab196087 bzero(argstate, sizeof (*argstate)); 150*5088Sab196087 argstate->obj_state = obj_state; 151*5088Sab196087 152*5088Sab196087 elfedit_getopt_init(&getopt_state, &argc, &argv); 153*5088Sab196087 154*5088Sab196087 /* Add each new option to the options mask */ 155*5088Sab196087 while ((getopt_ret = elfedit_getopt(&getopt_state)) != NULL) 156*5088Sab196087 argstate->optmask |= getopt_ret->gor_idmask; 157*5088Sab196087 158*5088Sab196087 /* Are the right number of plain arguments present? */ 159*5088Sab196087 switch (cmd) { 160*5088Sab196087 case SHDR_CMD_T_DUMP: 161*5088Sab196087 if (argc > 1) 162*5088Sab196087 elfedit_command_usage(); 163*5088Sab196087 break; 164*5088Sab196087 case SHDR_CMD_T_SH_FLAGS: 165*5088Sab196087 /* shdr:sh_flags allows an arbitrary number of arguments */ 166*5088Sab196087 break; 167*5088Sab196087 default: 168*5088Sab196087 /* The remaining commands accept 2 plain arguments */ 169*5088Sab196087 if (argc > 2) 170*5088Sab196087 elfedit_command_usage(); 171*5088Sab196087 break; 172*5088Sab196087 } 173*5088Sab196087 174*5088Sab196087 /* If there may be an arbitrary amount of output, use a pager */ 175*5088Sab196087 if (argc == 0) 176*5088Sab196087 elfedit_pager_init(); 177*5088Sab196087 178*5088Sab196087 /* Return the updated values of argc/argv */ 179*5088Sab196087 argstate->argc = argc; 180*5088Sab196087 argstate->argv = argv; 181*5088Sab196087 } 182*5088Sab196087 183*5088Sab196087 184*5088Sab196087 185*5088Sab196087 /* 186*5088Sab196087 * Print section header values, taking the calling command, and output style 187*5088Sab196087 * into account. 188*5088Sab196087 * 189*5088Sab196087 * entry: 190*5088Sab196087 * autoprint - If True, output is only produced if the elfedit 191*5088Sab196087 * autoprint flag is set. If False, output is always produced. 192*5088Sab196087 * cmd - SHDR_CMD_T_* value giving identify of caller 193*5088Sab196087 * argstate - State block for section header array 194*5088Sab196087 * ndx - Index of first section to display 195*5088Sab196087 * cnt - Number of sections to display 196*5088Sab196087 */ 197*5088Sab196087 static void 198*5088Sab196087 print_shdr(SHDR_CMD_T cmd, int autoprint, ARGSTATE *argstate, 199*5088Sab196087 Word ndx, Word cnt) 200*5088Sab196087 { 201*5088Sab196087 elfedit_outstyle_t outstyle; 202*5088Sab196087 203*5088Sab196087 if ((autoprint && ((elfedit_flags() & ELFEDIT_F_AUTOPRINT) == 0)) || 204*5088Sab196087 (cnt == 0)) 205*5088Sab196087 return; 206*5088Sab196087 207*5088Sab196087 /* 208*5088Sab196087 * Pick an output style. shdr:dump is required to use the default 209*5088Sab196087 * style. The other commands use the current output style. 210*5088Sab196087 */ 211*5088Sab196087 outstyle = (cmd == SHDR_CMD_T_DUMP) ? 212*5088Sab196087 ELFEDIT_OUTSTYLE_DEFAULT : elfedit_outstyle(); 213*5088Sab196087 214*5088Sab196087 /* 215*5088Sab196087 * If doing default output, use elfdump style where we 216*5088Sab196087 * show all section header attributes. In this case, the 217*5088Sab196087 * command that called us doesn't matter 218*5088Sab196087 */ 219*5088Sab196087 if (outstyle == ELFEDIT_OUTSTYLE_DEFAULT) { 220*5088Sab196087 Half mach = argstate->obj_state->os_ehdr->e_machine; 221*5088Sab196087 222*5088Sab196087 for (; cnt--; ndx++) { 223*5088Sab196087 elfedit_section_t *sec = 224*5088Sab196087 &argstate->obj_state->os_secarr[ndx]; 225*5088Sab196087 226*5088Sab196087 elfedit_printf(MSG_ORIG(MSG_STR_NL)); 227*5088Sab196087 elfedit_printf(MSG_INTL(MSG_ELF_SHDR), ndx, 228*5088Sab196087 sec->sec_name); 229*5088Sab196087 Elf_shdr(NULL, mach, sec->sec_shdr); 230*5088Sab196087 } 231*5088Sab196087 return; 232*5088Sab196087 } 233*5088Sab196087 234*5088Sab196087 235*5088Sab196087 switch (cmd) { 236*5088Sab196087 case SHDR_CMD_T_SH_ADDR: 237*5088Sab196087 for (; cnt--; ndx++) { 238*5088Sab196087 Shdr *shdr = 239*5088Sab196087 argstate->obj_state->os_secarr[ndx].sec_shdr; 240*5088Sab196087 241*5088Sab196087 elfedit_printf(MSG_ORIG(MSG_FMT_XWORDHEXNL), 242*5088Sab196087 EC_XWORD(shdr->sh_addr)); 243*5088Sab196087 } 244*5088Sab196087 return; 245*5088Sab196087 246*5088Sab196087 case SHDR_CMD_T_SH_ADDRALIGN: 247*5088Sab196087 for (; cnt--; ndx++) { 248*5088Sab196087 Shdr *shdr = 249*5088Sab196087 argstate->obj_state->os_secarr[ndx].sec_shdr; 250*5088Sab196087 251*5088Sab196087 elfedit_printf(MSG_ORIG(MSG_FMT_XWORDHEXNL), 252*5088Sab196087 EC_XWORD(shdr->sh_addralign)); 253*5088Sab196087 } 254*5088Sab196087 return; 255*5088Sab196087 256*5088Sab196087 case SHDR_CMD_T_SH_ENTSIZE: 257*5088Sab196087 for (; cnt--; ndx++) { 258*5088Sab196087 Shdr *shdr = 259*5088Sab196087 argstate->obj_state->os_secarr[ndx].sec_shdr; 260*5088Sab196087 261*5088Sab196087 elfedit_printf(MSG_ORIG(MSG_FMT_XWORDHEXNL), 262*5088Sab196087 EC_XWORD(shdr->sh_entsize)); 263*5088Sab196087 } 264*5088Sab196087 return; 265*5088Sab196087 266*5088Sab196087 case SHDR_CMD_T_SH_FLAGS: 267*5088Sab196087 for (; cnt--; ndx++) { 268*5088Sab196087 Shdr *shdr = 269*5088Sab196087 argstate->obj_state->os_secarr[ndx].sec_shdr; 270*5088Sab196087 if (outstyle == ELFEDIT_OUTSTYLE_SIMPLE) { 271*5088Sab196087 Conv_sec_flags_buf_t sec_flags_buf; 272*5088Sab196087 273*5088Sab196087 elfedit_printf(MSG_ORIG(MSG_FMT_STRNL), 274*5088Sab196087 conv_sec_flags(shdr->sh_flags, 275*5088Sab196087 CONV_FMT_NOBKT, &sec_flags_buf)); 276*5088Sab196087 } else { 277*5088Sab196087 elfedit_printf(MSG_ORIG(MSG_FMT_XWORDHEXNL), 278*5088Sab196087 EC_XWORD(shdr->sh_flags)); 279*5088Sab196087 } 280*5088Sab196087 } 281*5088Sab196087 return; 282*5088Sab196087 283*5088Sab196087 case SHDR_CMD_T_SH_INFO: 284*5088Sab196087 for (; cnt--; ndx++) { 285*5088Sab196087 Shdr *shdr = 286*5088Sab196087 argstate->obj_state->os_secarr[ndx].sec_shdr; 287*5088Sab196087 288*5088Sab196087 elfedit_printf(MSG_ORIG(MSG_FMT_WORDVALNL), 289*5088Sab196087 EC_WORD(shdr->sh_info)); 290*5088Sab196087 } 291*5088Sab196087 return; 292*5088Sab196087 293*5088Sab196087 case SHDR_CMD_T_SH_LINK: 294*5088Sab196087 for (; cnt--; ndx++) { 295*5088Sab196087 Shdr *shdr = 296*5088Sab196087 argstate->obj_state->os_secarr[ndx].sec_shdr; 297*5088Sab196087 298*5088Sab196087 elfedit_printf(MSG_ORIG(MSG_FMT_WORDVALNL), 299*5088Sab196087 EC_WORD(shdr->sh_link)); 300*5088Sab196087 } 301*5088Sab196087 return; 302*5088Sab196087 303*5088Sab196087 case SHDR_CMD_T_SH_NAME: 304*5088Sab196087 /* 305*5088Sab196087 * In simple output mode, we show the string. In numeric 306*5088Sab196087 * mode, we show the string table offset. 307*5088Sab196087 */ 308*5088Sab196087 for (; cnt--; ndx++) { 309*5088Sab196087 elfedit_section_t *shdr_sec = 310*5088Sab196087 &argstate->obj_state->os_secarr[ndx]; 311*5088Sab196087 312*5088Sab196087 if (outstyle == ELFEDIT_OUTSTYLE_SIMPLE) { 313*5088Sab196087 elfedit_printf(MSG_ORIG(MSG_FMT_STRNL), 314*5088Sab196087 shdr_sec->sec_name); 315*5088Sab196087 } else { 316*5088Sab196087 elfedit_printf(MSG_ORIG(MSG_FMT_WORDVALNL), 317*5088Sab196087 EC_WORD(shdr_sec->sec_shdr->sh_name)); 318*5088Sab196087 } 319*5088Sab196087 } 320*5088Sab196087 return; 321*5088Sab196087 322*5088Sab196087 case SHDR_CMD_T_SH_OFFSET: 323*5088Sab196087 for (; cnt--; ndx++) { 324*5088Sab196087 Shdr *shdr = 325*5088Sab196087 argstate->obj_state->os_secarr[ndx].sec_shdr; 326*5088Sab196087 327*5088Sab196087 elfedit_printf(MSG_ORIG(MSG_FMT_XWORDHEXNL), 328*5088Sab196087 EC_XWORD(shdr->sh_offset)); 329*5088Sab196087 } 330*5088Sab196087 return; 331*5088Sab196087 332*5088Sab196087 case SHDR_CMD_T_SH_SIZE: 333*5088Sab196087 for (; cnt--; ndx++) { 334*5088Sab196087 Shdr *shdr = 335*5088Sab196087 argstate->obj_state->os_secarr[ndx].sec_shdr; 336*5088Sab196087 337*5088Sab196087 elfedit_printf(MSG_ORIG(MSG_FMT_XWORDHEXNL), 338*5088Sab196087 EC_XWORD(shdr->sh_size)); 339*5088Sab196087 } 340*5088Sab196087 return; 341*5088Sab196087 342*5088Sab196087 case SHDR_CMD_T_SH_TYPE: 343*5088Sab196087 for (; cnt--; ndx++) { 344*5088Sab196087 Shdr *shdr = 345*5088Sab196087 argstate->obj_state->os_secarr[ndx].sec_shdr; 346*5088Sab196087 Conv_inv_buf_t inv_buf; 347*5088Sab196087 if (outstyle == ELFEDIT_OUTSTYLE_SIMPLE) { 348*5088Sab196087 Half mach = 349*5088Sab196087 argstate->obj_state->os_ehdr->e_machine; 350*5088Sab196087 351*5088Sab196087 elfedit_printf(MSG_ORIG(MSG_FMT_STRNL), 352*5088Sab196087 conv_sec_type(mach, shdr->sh_type, 0, 353*5088Sab196087 &inv_buf)); 354*5088Sab196087 } else { 355*5088Sab196087 elfedit_printf(MSG_ORIG(MSG_FMT_WORDHEXNL), 356*5088Sab196087 EC_WORD(shdr->sh_type)); 357*5088Sab196087 } 358*5088Sab196087 } 359*5088Sab196087 return; 360*5088Sab196087 } 361*5088Sab196087 } 362*5088Sab196087 363*5088Sab196087 364*5088Sab196087 /* 365*5088Sab196087 * Common body for the shdr: module commands. These commands 366*5088Sab196087 * share a large amount of common behavior, so it is convenient 367*5088Sab196087 * to centralize things and use the cmd argument to handle the 368*5088Sab196087 * small differences. 369*5088Sab196087 * 370*5088Sab196087 * entry: 371*5088Sab196087 * cmd - One of the SHDR_CMD_T_* constants listed above, specifying 372*5088Sab196087 * which command to implement. 373*5088Sab196087 * obj_state, argc, argv - Standard command arguments 374*5088Sab196087 */ 375*5088Sab196087 static elfedit_cmdret_t 376*5088Sab196087 cmd_body(SHDR_CMD_T cmd, elfedit_obj_state_t *obj_state, 377*5088Sab196087 int argc, const char *argv[]) 378*5088Sab196087 { 379*5088Sab196087 ARGSTATE argstate; 380*5088Sab196087 Word ndx; 381*5088Sab196087 elfedit_section_t *shdr_sec; 382*5088Sab196087 Shdr *shdr; 383*5088Sab196087 elfedit_cmdret_t ret = ELFEDIT_CMDRET_NONE; 384*5088Sab196087 385*5088Sab196087 process_args(obj_state, argc, argv, cmd, &argstate); 386*5088Sab196087 387*5088Sab196087 /* If there are no arguments, dump the whole table and return */ 388*5088Sab196087 if (argstate.argc == 0) { 389*5088Sab196087 print_shdr(cmd, 0, &argstate, 0, obj_state->os_shnum); 390*5088Sab196087 return (ELFEDIT_CMDRET_NONE); 391*5088Sab196087 } 392*5088Sab196087 393*5088Sab196087 /* 394*5088Sab196087 * The first argument gives the section to use. This can be a 395*5088Sab196087 * name (default), section index, or section type, depending on 396*5088Sab196087 * the options used. 397*5088Sab196087 */ 398*5088Sab196087 if (argstate.optmask & SHDR_OPT_F_SHNDX) 399*5088Sab196087 ndx = elfedit_atoshndx(argstate.argv[0], obj_state->os_shnum); 400*5088Sab196087 else if (argstate.optmask & SHDR_OPT_F_SHTYP) 401*5088Sab196087 ndx = elfedit_type_to_shndx(obj_state, 402*5088Sab196087 elfedit_atoconst(argstate.argv[0], ELFEDIT_CONST_SHT)); 403*5088Sab196087 else 404*5088Sab196087 ndx = elfedit_name_to_shndx(obj_state, argstate.argv[0]); 405*5088Sab196087 406*5088Sab196087 /* If there is a single argument, display that item and return */ 407*5088Sab196087 if (argstate.argc == 1) { 408*5088Sab196087 print_shdr(cmd, 0, &argstate, ndx, 1); 409*5088Sab196087 return (ELFEDIT_CMDRET_NONE); 410*5088Sab196087 } 411*5088Sab196087 412*5088Sab196087 /* 413*5088Sab196087 * Section [0] is supposed to be all zero unless extended sections 414*5088Sab196087 * are in force. Rather than setting extended values directly, 415*5088Sab196087 * it is expected to be handled by the ELF header module. So, a 416*5088Sab196087 * direct change here is probably not what was intended. 417*5088Sab196087 */ 418*5088Sab196087 if (ndx == 0) 419*5088Sab196087 elfedit_msg(ELFEDIT_MSG_DEBUG, MSG_INTL(MSG_DEBUG_CHGSHDR0)); 420*5088Sab196087 421*5088Sab196087 /* The second value is an integer giving a new value */ 422*5088Sab196087 shdr_sec = &obj_state->os_secarr[ndx]; 423*5088Sab196087 shdr = shdr_sec->sec_shdr; 424*5088Sab196087 switch (cmd) { 425*5088Sab196087 /* 426*5088Sab196087 * SHDR_CMD_T_DUMP can't get here: It never has more than 427*5088Sab196087 * one argument, and is handled above. 428*5088Sab196087 */ 429*5088Sab196087 430*5088Sab196087 case SHDR_CMD_T_SH_ADDR: 431*5088Sab196087 { 432*5088Sab196087 Addr sh_addr = elfedit_atoui(argstate.argv[1], NULL); 433*5088Sab196087 434*5088Sab196087 if (shdr->sh_addr == sh_addr) { 435*5088Sab196087 elfedit_msg(ELFEDIT_MSG_DEBUG, 436*5088Sab196087 MSG_INTL(MSG_DEBUG_LLX_OK), 437*5088Sab196087 ndx, shdr_sec->sec_name, 438*5088Sab196087 MSG_ORIG(MSG_CMD_SH_ADDR), 439*5088Sab196087 EC_ADDR(shdr->sh_addr)); 440*5088Sab196087 } else { 441*5088Sab196087 elfedit_msg(ELFEDIT_MSG_DEBUG, 442*5088Sab196087 MSG_INTL(MSG_DEBUG_LLX_CHG), 443*5088Sab196087 ndx, shdr_sec->sec_name, 444*5088Sab196087 MSG_ORIG(MSG_CMD_SH_ADDR), 445*5088Sab196087 EC_ADDR(shdr->sh_addr), EC_ADDR(sh_addr)); 446*5088Sab196087 ret = ELFEDIT_CMDRET_MOD; 447*5088Sab196087 shdr->sh_addr = sh_addr; 448*5088Sab196087 } 449*5088Sab196087 } 450*5088Sab196087 break; 451*5088Sab196087 452*5088Sab196087 case SHDR_CMD_T_SH_ADDRALIGN: 453*5088Sab196087 { 454*5088Sab196087 Xword sh_addralign; 455*5088Sab196087 456*5088Sab196087 sh_addralign = elfedit_atoui(argstate.argv[1], NULL); 457*5088Sab196087 if (elfedit_bits_set(sh_addralign, 458*5088Sab196087 sizeof (sh_addralign)) > 1) 459*5088Sab196087 elfedit_msg(ELFEDIT_MSG_DEBUG, 460*5088Sab196087 MSG_INTL(MSG_DEBUG_ADDRALIGN), 461*5088Sab196087 argstate.argv[1]); 462*5088Sab196087 if (shdr->sh_addralign == sh_addralign) { 463*5088Sab196087 elfedit_msg(ELFEDIT_MSG_DEBUG, 464*5088Sab196087 MSG_INTL(MSG_DEBUG_LLX_OK), 465*5088Sab196087 ndx, shdr_sec->sec_name, 466*5088Sab196087 MSG_ORIG(MSG_CMD_SH_ADDRALIGN), 467*5088Sab196087 EC_XWORD(shdr->sh_addralign)); 468*5088Sab196087 } else { 469*5088Sab196087 elfedit_msg(ELFEDIT_MSG_DEBUG, 470*5088Sab196087 MSG_INTL(MSG_DEBUG_LLX_CHG), 471*5088Sab196087 ndx, shdr_sec->sec_name, 472*5088Sab196087 MSG_ORIG(MSG_CMD_SH_ADDRALIGN), 473*5088Sab196087 EC_XWORD(shdr->sh_addralign), 474*5088Sab196087 EC_XWORD(sh_addralign)); 475*5088Sab196087 ret = ELFEDIT_CMDRET_MOD; 476*5088Sab196087 shdr->sh_addralign = sh_addralign; 477*5088Sab196087 } 478*5088Sab196087 } 479*5088Sab196087 break; 480*5088Sab196087 481*5088Sab196087 case SHDR_CMD_T_SH_ENTSIZE: 482*5088Sab196087 { 483*5088Sab196087 Xword sh_entsize; 484*5088Sab196087 485*5088Sab196087 sh_entsize = elfedit_atoui(argstate.argv[1], NULL); 486*5088Sab196087 if (shdr->sh_entsize == sh_entsize) { 487*5088Sab196087 elfedit_msg(ELFEDIT_MSG_DEBUG, 488*5088Sab196087 MSG_INTL(MSG_DEBUG_LLX_OK), 489*5088Sab196087 ndx, shdr_sec->sec_name, 490*5088Sab196087 MSG_ORIG(MSG_CMD_SH_ENTSIZE), 491*5088Sab196087 EC_XWORD(shdr->sh_entsize)); 492*5088Sab196087 } else { 493*5088Sab196087 elfedit_msg(ELFEDIT_MSG_DEBUG, 494*5088Sab196087 MSG_INTL(MSG_DEBUG_LLX_CHG), 495*5088Sab196087 ndx, shdr_sec->sec_name, 496*5088Sab196087 MSG_ORIG(MSG_CMD_SH_ENTSIZE), 497*5088Sab196087 EC_XWORD(shdr->sh_entsize), 498*5088Sab196087 EC_XWORD(sh_entsize)); 499*5088Sab196087 ret = ELFEDIT_CMDRET_MOD; 500*5088Sab196087 shdr->sh_entsize = sh_entsize; 501*5088Sab196087 } 502*5088Sab196087 } 503*5088Sab196087 break; 504*5088Sab196087 505*5088Sab196087 case SHDR_CMD_T_SH_FLAGS: 506*5088Sab196087 { 507*5088Sab196087 Conv_sec_flags_buf_t buf1, buf2; 508*5088Sab196087 Word sh_flags = 0; 509*5088Sab196087 int i; 510*5088Sab196087 511*5088Sab196087 /* Collect the flag arguments */ 512*5088Sab196087 for (i = 1; i < argstate.argc; i++) 513*5088Sab196087 sh_flags |= 514*5088Sab196087 (Word) elfedit_atoconst(argstate.argv[i], 515*5088Sab196087 ELFEDIT_CONST_SHF); 516*5088Sab196087 517*5088Sab196087 /* Complement the value? */ 518*5088Sab196087 if (argstate.optmask & SHDR_OPT_F_CMP) 519*5088Sab196087 sh_flags = ~sh_flags; 520*5088Sab196087 521*5088Sab196087 /* Perform any requested bit operations */ 522*5088Sab196087 if (argstate.optmask & SHDR_OPT_F_AND) 523*5088Sab196087 sh_flags &= shdr->sh_flags; 524*5088Sab196087 else if (argstate.optmask & SHDR_OPT_F_OR) 525*5088Sab196087 sh_flags |= shdr->sh_flags; 526*5088Sab196087 527*5088Sab196087 /* Set the value */ 528*5088Sab196087 if (shdr->sh_flags == sh_flags) { 529*5088Sab196087 elfedit_msg(ELFEDIT_MSG_DEBUG, 530*5088Sab196087 MSG_INTL(MSG_DEBUG_S_OK), 531*5088Sab196087 ndx, shdr_sec->sec_name, 532*5088Sab196087 MSG_ORIG(MSG_CMD_SH_FLAGS), 533*5088Sab196087 conv_sec_flags(shdr->sh_flags, 0, &buf1)); 534*5088Sab196087 } else { 535*5088Sab196087 elfedit_msg(ELFEDIT_MSG_DEBUG, 536*5088Sab196087 MSG_INTL(MSG_DEBUG_S_CHG), 537*5088Sab196087 ndx, shdr_sec->sec_name, 538*5088Sab196087 MSG_ORIG(MSG_CMD_SH_FLAGS), 539*5088Sab196087 conv_sec_flags(shdr->sh_flags, 0, &buf1), 540*5088Sab196087 conv_sec_flags(sh_flags, 0, &buf2)); 541*5088Sab196087 ret = ELFEDIT_CMDRET_MOD; 542*5088Sab196087 shdr->sh_flags = sh_flags; 543*5088Sab196087 } 544*5088Sab196087 } 545*5088Sab196087 break; 546*5088Sab196087 547*5088Sab196087 case SHDR_CMD_T_SH_INFO: 548*5088Sab196087 { 549*5088Sab196087 Word sh_info = elfedit_atoui(argstate.argv[1], NULL); 550*5088Sab196087 551*5088Sab196087 if (shdr->sh_info == sh_info) { 552*5088Sab196087 elfedit_msg(ELFEDIT_MSG_DEBUG, 553*5088Sab196087 MSG_INTL(MSG_DEBUG_D_OK), 554*5088Sab196087 ndx, shdr_sec->sec_name, 555*5088Sab196087 MSG_ORIG(MSG_CMD_SH_INFO), 556*5088Sab196087 EC_WORD(shdr->sh_info)); 557*5088Sab196087 } else { 558*5088Sab196087 elfedit_msg(ELFEDIT_MSG_DEBUG, 559*5088Sab196087 MSG_INTL(MSG_DEBUG_D_CHG), 560*5088Sab196087 ndx, shdr_sec->sec_name, 561*5088Sab196087 MSG_ORIG(MSG_CMD_SH_INFO), 562*5088Sab196087 EC_WORD(shdr->sh_info), EC_WORD(sh_info)); 563*5088Sab196087 ret = ELFEDIT_CMDRET_MOD; 564*5088Sab196087 shdr->sh_info = sh_info; 565*5088Sab196087 } 566*5088Sab196087 } 567*5088Sab196087 break; 568*5088Sab196087 569*5088Sab196087 case SHDR_CMD_T_SH_LINK: 570*5088Sab196087 { 571*5088Sab196087 Word sh_link = elfedit_atoui(argstate.argv[1], NULL); 572*5088Sab196087 573*5088Sab196087 if (shdr->sh_link == sh_link) { 574*5088Sab196087 elfedit_msg(ELFEDIT_MSG_DEBUG, 575*5088Sab196087 MSG_INTL(MSG_DEBUG_D_OK), 576*5088Sab196087 ndx, shdr_sec->sec_name, 577*5088Sab196087 MSG_ORIG(MSG_CMD_SH_LINK), 578*5088Sab196087 EC_WORD(shdr->sh_link)); 579*5088Sab196087 } else { 580*5088Sab196087 elfedit_msg(ELFEDIT_MSG_DEBUG, 581*5088Sab196087 MSG_INTL(MSG_DEBUG_D_CHG), 582*5088Sab196087 ndx, shdr_sec->sec_name, 583*5088Sab196087 MSG_ORIG(MSG_CMD_SH_LINK), 584*5088Sab196087 EC_WORD(shdr->sh_link), EC_WORD(sh_link)); 585*5088Sab196087 ret = ELFEDIT_CMDRET_MOD; 586*5088Sab196087 shdr->sh_link = sh_link; 587*5088Sab196087 } 588*5088Sab196087 } 589*5088Sab196087 break; 590*5088Sab196087 591*5088Sab196087 case SHDR_CMD_T_SH_NAME: 592*5088Sab196087 { 593*5088Sab196087 elfedit_section_t *shstr_sec = 594*5088Sab196087 &obj_state->os_secarr[obj_state->os_shstrndx]; 595*5088Sab196087 Word sh_name; 596*5088Sab196087 597*5088Sab196087 /* 598*5088Sab196087 * If -name_offset was specified, this is an offset 599*5088Sab196087 * into the string table. Otherwise it is a string 600*5088Sab196087 * we need to turn into an offset. 601*5088Sab196087 */ 602*5088Sab196087 sh_name = (argstate.optmask & SHDR_OPT_F_NAMOFFSET) ? 603*5088Sab196087 elfedit_atoui(argstate.argv[1], NULL) : 604*5088Sab196087 elfedit_strtab_insert(obj_state, 605*5088Sab196087 shstr_sec, NULL, argstate.argv[1]); 606*5088Sab196087 if (shdr->sh_name == sh_name) { 607*5088Sab196087 elfedit_msg(ELFEDIT_MSG_DEBUG, 608*5088Sab196087 MSG_INTL(MSG_DEBUG_D_OK), 609*5088Sab196087 ndx, shdr_sec->sec_name, 610*5088Sab196087 MSG_ORIG(MSG_CMD_SH_NAME), 611*5088Sab196087 EC_WORD(shdr->sh_name)); 612*5088Sab196087 } else { 613*5088Sab196087 /* 614*5088Sab196087 * The section name is cached, so we must 615*5088Sab196087 * also update that value. This call will 616*5088Sab196087 * warn if the offset is out of range, and 617*5088Sab196087 * will supply a safe string in that case. 618*5088Sab196087 */ 619*5088Sab196087 shdr_sec->sec_name = 620*5088Sab196087 elfedit_offset_to_str(shstr_sec, 621*5088Sab196087 sh_name, ELFEDIT_MSG_DEBUG, 1); 622*5088Sab196087 623*5088Sab196087 elfedit_msg(ELFEDIT_MSG_DEBUG, 624*5088Sab196087 MSG_INTL(MSG_DEBUG_D_CHG), 625*5088Sab196087 ndx, shdr_sec->sec_name, 626*5088Sab196087 MSG_ORIG(MSG_CMD_SH_NAME), 627*5088Sab196087 EC_WORD(shdr->sh_name), EC_WORD(sh_name)); 628*5088Sab196087 ret = ELFEDIT_CMDRET_MOD; 629*5088Sab196087 shdr->sh_name = sh_name; 630*5088Sab196087 } 631*5088Sab196087 } 632*5088Sab196087 break; 633*5088Sab196087 634*5088Sab196087 case SHDR_CMD_T_SH_OFFSET: 635*5088Sab196087 { 636*5088Sab196087 Off sh_offset; 637*5088Sab196087 638*5088Sab196087 sh_offset = elfedit_atoui(argstate.argv[1], NULL); 639*5088Sab196087 if (shdr->sh_offset == sh_offset) { 640*5088Sab196087 elfedit_msg(ELFEDIT_MSG_DEBUG, 641*5088Sab196087 MSG_INTL(MSG_DEBUG_LLX_OK), 642*5088Sab196087 ndx, shdr_sec->sec_name, 643*5088Sab196087 MSG_ORIG(MSG_CMD_SH_OFFSET), 644*5088Sab196087 EC_XWORD(shdr->sh_offset)); 645*5088Sab196087 } else { 646*5088Sab196087 elfedit_msg(ELFEDIT_MSG_DEBUG, 647*5088Sab196087 MSG_INTL(MSG_DEBUG_LLX_CHG), 648*5088Sab196087 ndx, shdr_sec->sec_name, 649*5088Sab196087 MSG_ORIG(MSG_CMD_SH_OFFSET), 650*5088Sab196087 EC_XWORD(shdr->sh_offset), 651*5088Sab196087 EC_XWORD(sh_offset)); 652*5088Sab196087 ret = ELFEDIT_CMDRET_MOD; 653*5088Sab196087 shdr->sh_offset = sh_offset; 654*5088Sab196087 } 655*5088Sab196087 } 656*5088Sab196087 break; 657*5088Sab196087 658*5088Sab196087 case SHDR_CMD_T_SH_SIZE: 659*5088Sab196087 { 660*5088Sab196087 Xword sh_size; 661*5088Sab196087 662*5088Sab196087 sh_size = elfedit_atoui(argstate.argv[1], NULL); 663*5088Sab196087 if (shdr->sh_size == sh_size) { 664*5088Sab196087 elfedit_msg(ELFEDIT_MSG_DEBUG, 665*5088Sab196087 MSG_INTL(MSG_DEBUG_LLX_OK), 666*5088Sab196087 ndx, shdr_sec->sec_name, 667*5088Sab196087 MSG_ORIG(MSG_CMD_SH_SIZE), 668*5088Sab196087 EC_XWORD(shdr->sh_size)); 669*5088Sab196087 } else { 670*5088Sab196087 elfedit_msg(ELFEDIT_MSG_DEBUG, 671*5088Sab196087 MSG_INTL(MSG_DEBUG_LLX_CHG), 672*5088Sab196087 ndx, shdr_sec->sec_name, 673*5088Sab196087 MSG_ORIG(MSG_CMD_SH_SIZE), 674*5088Sab196087 EC_XWORD(shdr->sh_size), 675*5088Sab196087 EC_XWORD(sh_size)); 676*5088Sab196087 ret = ELFEDIT_CMDRET_MOD; 677*5088Sab196087 shdr->sh_size = sh_size; 678*5088Sab196087 } 679*5088Sab196087 } 680*5088Sab196087 break; 681*5088Sab196087 682*5088Sab196087 case SHDR_CMD_T_SH_TYPE: 683*5088Sab196087 { 684*5088Sab196087 Half mach = obj_state->os_ehdr->e_machine; 685*5088Sab196087 Word sh_type = elfedit_atoconst(argstate.argv[1], 686*5088Sab196087 ELFEDIT_CONST_SHT); 687*5088Sab196087 Conv_inv_buf_t inv_buf1, inv_buf2; 688*5088Sab196087 689*5088Sab196087 if (shdr->sh_type == sh_type) { 690*5088Sab196087 elfedit_msg(ELFEDIT_MSG_DEBUG, 691*5088Sab196087 MSG_INTL(MSG_DEBUG_S_OK), 692*5088Sab196087 ndx, shdr_sec->sec_name, 693*5088Sab196087 MSG_ORIG(MSG_CMD_SH_TYPE), 694*5088Sab196087 conv_sec_type(mach, shdr->sh_type, 695*5088Sab196087 0, &inv_buf1)); 696*5088Sab196087 } else { 697*5088Sab196087 elfedit_msg(ELFEDIT_MSG_DEBUG, 698*5088Sab196087 MSG_INTL(MSG_DEBUG_S_CHG), 699*5088Sab196087 ndx, shdr_sec->sec_name, 700*5088Sab196087 MSG_ORIG(MSG_CMD_SH_TYPE), 701*5088Sab196087 conv_sec_type(mach, shdr->sh_type, 0, 702*5088Sab196087 &inv_buf1), 703*5088Sab196087 conv_sec_type(mach, sh_type, 0, &inv_buf2)); 704*5088Sab196087 ret = ELFEDIT_CMDRET_MOD; 705*5088Sab196087 shdr->sh_type = sh_type; 706*5088Sab196087 } 707*5088Sab196087 } 708*5088Sab196087 break; 709*5088Sab196087 } 710*5088Sab196087 711*5088Sab196087 /* 712*5088Sab196087 * If we modified the section header array, tell libelf. 713*5088Sab196087 */ 714*5088Sab196087 if (ret == ELFEDIT_CMDRET_MOD) 715*5088Sab196087 elfedit_modified_shdr(shdr_sec); 716*5088Sab196087 717*5088Sab196087 /* Do autoprint */ 718*5088Sab196087 print_shdr(cmd, 1, &argstate, ndx, 1); 719*5088Sab196087 720*5088Sab196087 return (ret); 721*5088Sab196087 } 722*5088Sab196087 723*5088Sab196087 724*5088Sab196087 725*5088Sab196087 726*5088Sab196087 /* 727*5088Sab196087 * Command completion functions for the various commands 728*5088Sab196087 */ 729*5088Sab196087 730*5088Sab196087 /* 731*5088Sab196087 * All of the commands accept the same first argument (sec) that 732*5088Sab196087 * specifies the section. This argument can be a section name 733*5088Sab196087 * (default), section index, or section type, depending on the 734*5088Sab196087 * options used. This routine determines which case is current, 735*5088Sab196087 * and then supplies completion for the first argument. 736*5088Sab196087 */ 737*5088Sab196087 static void 738*5088Sab196087 cpl_1starg_sec(elfedit_obj_state_t *obj_state, void *cpldata, int argc, 739*5088Sab196087 const char *argv[], int num_opt) 740*5088Sab196087 { 741*5088Sab196087 elfedit_section_t *sec; 742*5088Sab196087 enum { NAME, INDEX, TYPE } op; 743*5088Sab196087 Word ndx; 744*5088Sab196087 745*5088Sab196087 if (argc != (num_opt + 1)) 746*5088Sab196087 return; 747*5088Sab196087 748*5088Sab196087 op = NAME; 749*5088Sab196087 for (ndx = 0; ndx < num_opt; ndx++) { 750*5088Sab196087 if (strcmp(argv[ndx], MSG_ORIG(MSG_STR_MINUS_SHNDX)) == 0) 751*5088Sab196087 op = INDEX; 752*5088Sab196087 else if (strcmp(argv[ndx], MSG_ORIG(MSG_STR_MINUS_SHTYP)) == 0) 753*5088Sab196087 op = TYPE; 754*5088Sab196087 } 755*5088Sab196087 756*5088Sab196087 switch (op) { 757*5088Sab196087 case NAME: 758*5088Sab196087 if (obj_state == NULL) 759*5088Sab196087 break; 760*5088Sab196087 sec = obj_state->os_secarr; 761*5088Sab196087 for (ndx = 0; ndx < obj_state->os_shnum; ndx++, sec++) 762*5088Sab196087 elfedit_cpl_match(cpldata, sec->sec_name, 0); 763*5088Sab196087 break; 764*5088Sab196087 765*5088Sab196087 case INDEX: 766*5088Sab196087 elfedit_cpl_atoconst(cpldata, ELFEDIT_CONST_SHN); 767*5088Sab196087 break; 768*5088Sab196087 769*5088Sab196087 case TYPE: 770*5088Sab196087 elfedit_cpl_atoconst(cpldata, ELFEDIT_CONST_SHT); 771*5088Sab196087 break; 772*5088Sab196087 } 773*5088Sab196087 } 774*5088Sab196087 775*5088Sab196087 776*5088Sab196087 /*ARGSUSED*/ 777*5088Sab196087 static void 778*5088Sab196087 cpl_sh_flags(elfedit_obj_state_t *obj_state, void *cpldata, int argc, 779*5088Sab196087 const char *argv[], int num_opt) 780*5088Sab196087 { 781*5088Sab196087 /* Handle -shXXX options */ 782*5088Sab196087 cpl_1starg_sec(obj_state, cpldata, argc, argv, num_opt); 783*5088Sab196087 784*5088Sab196087 /* The second and following arguments can be an SHF_ value */ 785*5088Sab196087 if (argc >= (num_opt + 2)) 786*5088Sab196087 elfedit_cpl_atoconst(cpldata, ELFEDIT_CONST_SHF); 787*5088Sab196087 } 788*5088Sab196087 789*5088Sab196087 /*ARGSUSED*/ 790*5088Sab196087 static void 791*5088Sab196087 cpl_sh_type(elfedit_obj_state_t *obj_state, void *cpldata, int argc, 792*5088Sab196087 const char *argv[], int num_opt) 793*5088Sab196087 { 794*5088Sab196087 /* Handle -shXXX options */ 795*5088Sab196087 cpl_1starg_sec(obj_state, cpldata, argc, argv, num_opt); 796*5088Sab196087 797*5088Sab196087 /* The second argument can be an SHT_ value */ 798*5088Sab196087 if (argc == (num_opt + 2)) 799*5088Sab196087 elfedit_cpl_atoconst(cpldata, ELFEDIT_CONST_SHT); 800*5088Sab196087 } 801*5088Sab196087 802*5088Sab196087 803*5088Sab196087 804*5088Sab196087 /* 805*5088Sab196087 * Implementation functions for the commands 806*5088Sab196087 */ 807*5088Sab196087 static elfedit_cmdret_t 808*5088Sab196087 cmd_dump(elfedit_obj_state_t *obj_state, int argc, const char *argv[]) 809*5088Sab196087 { 810*5088Sab196087 return (cmd_body(SHDR_CMD_T_DUMP, obj_state, argc, argv)); 811*5088Sab196087 } 812*5088Sab196087 813*5088Sab196087 814*5088Sab196087 static elfedit_cmdret_t 815*5088Sab196087 cmd_sh_addr(elfedit_obj_state_t *obj_state, int argc, const char *argv[]) 816*5088Sab196087 { 817*5088Sab196087 return (cmd_body(SHDR_CMD_T_SH_ADDR, obj_state, argc, argv)); 818*5088Sab196087 } 819*5088Sab196087 820*5088Sab196087 821*5088Sab196087 static elfedit_cmdret_t 822*5088Sab196087 cmd_sh_addralign(elfedit_obj_state_t *obj_state, int argc, const char *argv[]) 823*5088Sab196087 { 824*5088Sab196087 return (cmd_body(SHDR_CMD_T_SH_ADDRALIGN, obj_state, argc, argv)); 825*5088Sab196087 } 826*5088Sab196087 827*5088Sab196087 828*5088Sab196087 static elfedit_cmdret_t 829*5088Sab196087 cmd_sh_entsize(elfedit_obj_state_t *obj_state, int argc, const char *argv[]) 830*5088Sab196087 { 831*5088Sab196087 return (cmd_body(SHDR_CMD_T_SH_ENTSIZE, obj_state, argc, argv)); 832*5088Sab196087 } 833*5088Sab196087 834*5088Sab196087 static elfedit_cmdret_t 835*5088Sab196087 cmd_sh_flags(elfedit_obj_state_t *obj_state, int argc, const char *argv[]) 836*5088Sab196087 { 837*5088Sab196087 return (cmd_body(SHDR_CMD_T_SH_FLAGS, obj_state, argc, argv)); 838*5088Sab196087 } 839*5088Sab196087 840*5088Sab196087 static elfedit_cmdret_t 841*5088Sab196087 cmd_sh_info(elfedit_obj_state_t *obj_state, int argc, const char *argv[]) 842*5088Sab196087 { 843*5088Sab196087 return (cmd_body(SHDR_CMD_T_SH_INFO, obj_state, argc, argv)); 844*5088Sab196087 } 845*5088Sab196087 846*5088Sab196087 static elfedit_cmdret_t 847*5088Sab196087 cmd_sh_link(elfedit_obj_state_t *obj_state, int argc, const char *argv[]) 848*5088Sab196087 { 849*5088Sab196087 return (cmd_body(SHDR_CMD_T_SH_LINK, obj_state, argc, argv)); 850*5088Sab196087 } 851*5088Sab196087 852*5088Sab196087 static elfedit_cmdret_t 853*5088Sab196087 cmd_sh_name(elfedit_obj_state_t *obj_state, int argc, const char *argv[]) 854*5088Sab196087 { 855*5088Sab196087 return (cmd_body(SHDR_CMD_T_SH_NAME, obj_state, argc, argv)); 856*5088Sab196087 } 857*5088Sab196087 858*5088Sab196087 static elfedit_cmdret_t 859*5088Sab196087 cmd_sh_offset(elfedit_obj_state_t *obj_state, int argc, const char *argv[]) 860*5088Sab196087 { 861*5088Sab196087 return (cmd_body(SHDR_CMD_T_SH_OFFSET, obj_state, argc, argv)); 862*5088Sab196087 } 863*5088Sab196087 864*5088Sab196087 static elfedit_cmdret_t 865*5088Sab196087 cmd_sh_size(elfedit_obj_state_t *obj_state, int argc, const char *argv[]) 866*5088Sab196087 { 867*5088Sab196087 return (cmd_body(SHDR_CMD_T_SH_SIZE, obj_state, argc, argv)); 868*5088Sab196087 } 869*5088Sab196087 870*5088Sab196087 static elfedit_cmdret_t 871*5088Sab196087 cmd_sh_type(elfedit_obj_state_t *obj_state, int argc, const char *argv[]) 872*5088Sab196087 { 873*5088Sab196087 return (cmd_body(SHDR_CMD_T_SH_TYPE, obj_state, argc, argv)); 874*5088Sab196087 } 875*5088Sab196087 876*5088Sab196087 877*5088Sab196087 878*5088Sab196087 /*ARGSUSED*/ 879*5088Sab196087 elfedit_module_t * 880*5088Sab196087 elfedit_init(elfedit_module_version_t version) 881*5088Sab196087 { 882*5088Sab196087 /* Multiple commands accept only the standard set of options */ 883*5088Sab196087 static elfedit_cmd_optarg_t opt_std[] = { 884*5088Sab196087 { ELFEDIT_STDOA_OPT_O, NULL, 885*5088Sab196087 ELFEDIT_CMDOA_F_INHERIT, 0, 0 }, 886*5088Sab196087 { MSG_ORIG(MSG_STR_MINUS_SHNDX), 887*5088Sab196087 /* MSG_INTL(MSG_OPTDESC_SHNDX) */ 888*5088Sab196087 ELFEDIT_I18NHDL(MSG_OPTDESC_SHNDX), 0, 889*5088Sab196087 SHDR_OPT_F_SHNDX, SHDR_OPT_F_SHTYP }, 890*5088Sab196087 { MSG_ORIG(MSG_STR_MINUS_SHTYP), 891*5088Sab196087 /* MSG_INTL(MSG_OPTDESC_SHTYP) */ 892*5088Sab196087 ELFEDIT_I18NHDL(MSG_OPTDESC_SHTYP), 0, 893*5088Sab196087 SHDR_OPT_F_SHTYP, SHDR_OPT_F_SHNDX }, 894*5088Sab196087 { NULL } 895*5088Sab196087 }; 896*5088Sab196087 897*5088Sab196087 /* shdr:sh_addr */ 898*5088Sab196087 static const char *name_sh_addr[] = { 899*5088Sab196087 MSG_ORIG(MSG_CMD_SH_ADDR), NULL }; 900*5088Sab196087 static elfedit_cmd_optarg_t arg_sh_addr[] = { 901*5088Sab196087 { MSG_ORIG(MSG_STR_SEC), 902*5088Sab196087 /* MSG_INTL(MSG_A1_SEC) */ 903*5088Sab196087 ELFEDIT_I18NHDL(MSG_A1_SEC), 904*5088Sab196087 ELFEDIT_CMDOA_F_OPT }, 905*5088Sab196087 { MSG_ORIG(MSG_STR_VALUE), 906*5088Sab196087 /* MSG_INTL(MSG_A2_DESC_SH_ADDR) */ 907*5088Sab196087 ELFEDIT_I18NHDL(MSG_A2_DESC_SH_ADDR), 908*5088Sab196087 ELFEDIT_CMDOA_F_OPT }, 909*5088Sab196087 { NULL } 910*5088Sab196087 }; 911*5088Sab196087 912*5088Sab196087 /* shdr:dump */ 913*5088Sab196087 static const char *name_dump[] = { 914*5088Sab196087 MSG_ORIG(MSG_CMD_DUMP), 915*5088Sab196087 MSG_ORIG(MSG_STR_EMPTY), /* "" makes this the default command */ 916*5088Sab196087 NULL 917*5088Sab196087 }; 918*5088Sab196087 static elfedit_cmd_optarg_t opt_dump[] = { 919*5088Sab196087 { MSG_ORIG(MSG_STR_MINUS_SHNDX), 920*5088Sab196087 /* MSG_INTL(MSG_OPTDESC_SHNDX) */ 921*5088Sab196087 ELFEDIT_I18NHDL(MSG_OPTDESC_SHNDX), 0, 922*5088Sab196087 SHDR_OPT_F_SHNDX, SHDR_OPT_F_SHTYP }, 923*5088Sab196087 { MSG_ORIG(MSG_STR_MINUS_SHTYP), 924*5088Sab196087 /* MSG_INTL(MSG_OPTDESC_SHTYP) */ 925*5088Sab196087 ELFEDIT_I18NHDL(MSG_OPTDESC_SHTYP), 0, 926*5088Sab196087 SHDR_OPT_F_SHTYP, SHDR_OPT_F_SHNDX }, 927*5088Sab196087 { NULL } 928*5088Sab196087 }; 929*5088Sab196087 static elfedit_cmd_optarg_t arg_dump[] = { 930*5088Sab196087 { MSG_ORIG(MSG_STR_SEC), 931*5088Sab196087 /* MSG_INTL(MSG_A1_SEC) */ 932*5088Sab196087 ELFEDIT_I18NHDL(MSG_A1_SEC), 933*5088Sab196087 ELFEDIT_CMDOA_F_OPT }, 934*5088Sab196087 { NULL } 935*5088Sab196087 }; 936*5088Sab196087 937*5088Sab196087 /* shdr:sh_addralign */ 938*5088Sab196087 static const char *name_sh_addralign[] = { 939*5088Sab196087 MSG_ORIG(MSG_CMD_SH_ADDRALIGN), NULL }; 940*5088Sab196087 static elfedit_cmd_optarg_t arg_sh_addralign[] = { 941*5088Sab196087 { MSG_ORIG(MSG_STR_SEC), 942*5088Sab196087 /* MSG_INTL(MSG_A1_SEC) */ 943*5088Sab196087 ELFEDIT_I18NHDL(MSG_A1_SEC), 944*5088Sab196087 ELFEDIT_CMDOA_F_OPT }, 945*5088Sab196087 { MSG_ORIG(MSG_STR_VALUE), 946*5088Sab196087 /* MSG_INTL(MSG_A2_DESC_SH_ADDRALIGN) */ 947*5088Sab196087 ELFEDIT_I18NHDL(MSG_A2_DESC_SH_ADDRALIGN), 948*5088Sab196087 ELFEDIT_CMDOA_F_OPT }, 949*5088Sab196087 { NULL } 950*5088Sab196087 }; 951*5088Sab196087 952*5088Sab196087 /* shdr:sh_entsize */ 953*5088Sab196087 static const char *name_sh_entsize[] = { 954*5088Sab196087 MSG_ORIG(MSG_CMD_SH_ENTSIZE), NULL }; 955*5088Sab196087 static elfedit_cmd_optarg_t arg_sh_entsize[] = { 956*5088Sab196087 { MSG_ORIG(MSG_STR_SEC), 957*5088Sab196087 /* MSG_INTL(MSG_A1_SEC) */ 958*5088Sab196087 ELFEDIT_I18NHDL(MSG_A1_SEC), 959*5088Sab196087 ELFEDIT_CMDOA_F_OPT }, 960*5088Sab196087 { MSG_ORIG(MSG_STR_VALUE), 961*5088Sab196087 /* MSG_INTL(MSG_A2_DESC_SH_ENTSIZE) */ 962*5088Sab196087 ELFEDIT_I18NHDL(MSG_A2_DESC_SH_ENTSIZE), 963*5088Sab196087 ELFEDIT_CMDOA_F_OPT }, 964*5088Sab196087 { NULL } 965*5088Sab196087 }; 966*5088Sab196087 967*5088Sab196087 /* shdr:sh_flags */ 968*5088Sab196087 static const char *name_sh_flags[] = { 969*5088Sab196087 MSG_ORIG(MSG_CMD_SH_FLAGS), NULL }; 970*5088Sab196087 static elfedit_cmd_optarg_t opt_sh_flags[] = { 971*5088Sab196087 { ELFEDIT_STDOA_OPT_AND, NULL, 972*5088Sab196087 ELFEDIT_CMDOA_F_INHERIT, SHDR_OPT_F_AND, SHDR_OPT_F_OR }, 973*5088Sab196087 { ELFEDIT_STDOA_OPT_CMP, NULL, 974*5088Sab196087 ELFEDIT_CMDOA_F_INHERIT, SHDR_OPT_F_CMP, 0 }, 975*5088Sab196087 { ELFEDIT_STDOA_OPT_O, NULL, 976*5088Sab196087 ELFEDIT_CMDOA_F_INHERIT, 0, 0 }, 977*5088Sab196087 { ELFEDIT_STDOA_OPT_OR, NULL, 978*5088Sab196087 ELFEDIT_CMDOA_F_INHERIT, SHDR_OPT_F_OR, SHDR_OPT_F_AND }, 979*5088Sab196087 { MSG_ORIG(MSG_STR_MINUS_SHNDX), 980*5088Sab196087 /* MSG_INTL(MSG_OPTDESC_SHNDX) */ 981*5088Sab196087 ELFEDIT_I18NHDL(MSG_OPTDESC_SHNDX), 0, 982*5088Sab196087 SHDR_OPT_F_SHNDX, SHDR_OPT_F_SHTYP }, 983*5088Sab196087 { MSG_ORIG(MSG_STR_MINUS_SHTYP), 984*5088Sab196087 /* MSG_INTL(MSG_OPTDESC_SHTYP) */ 985*5088Sab196087 ELFEDIT_I18NHDL(MSG_OPTDESC_SHTYP), 0, 986*5088Sab196087 SHDR_OPT_F_SHTYP, SHDR_OPT_F_SHNDX }, 987*5088Sab196087 { NULL } 988*5088Sab196087 }; 989*5088Sab196087 static elfedit_cmd_optarg_t arg_sh_flags[] = { 990*5088Sab196087 { MSG_ORIG(MSG_STR_SEC), 991*5088Sab196087 /* MSG_INTL(MSG_A1_SEC) */ 992*5088Sab196087 ELFEDIT_I18NHDL(MSG_A1_SEC), 993*5088Sab196087 ELFEDIT_CMDOA_F_OPT }, 994*5088Sab196087 { MSG_ORIG(MSG_STR_VALUE), 995*5088Sab196087 /* MSG_INTL(MSG_A2_DESC_SH_FLAGS) */ 996*5088Sab196087 ELFEDIT_I18NHDL(MSG_A2_DESC_SH_FLAGS), 997*5088Sab196087 ELFEDIT_CMDOA_F_OPT | ELFEDIT_CMDOA_F_MULT }, 998*5088Sab196087 { NULL } 999*5088Sab196087 }; 1000*5088Sab196087 1001*5088Sab196087 /* shdr:sh_info */ 1002*5088Sab196087 static const char *name_sh_info[] = { 1003*5088Sab196087 MSG_ORIG(MSG_CMD_SH_INFO), NULL }; 1004*5088Sab196087 static elfedit_cmd_optarg_t arg_sh_info[] = { 1005*5088Sab196087 { MSG_ORIG(MSG_STR_SEC), 1006*5088Sab196087 /* MSG_INTL(MSG_A1_SEC) */ 1007*5088Sab196087 ELFEDIT_I18NHDL(MSG_A1_SEC), 1008*5088Sab196087 ELFEDIT_CMDOA_F_OPT }, 1009*5088Sab196087 { MSG_ORIG(MSG_STR_VALUE), 1010*5088Sab196087 /* MSG_INTL(MSG_A2_DESC_SH_INFO) */ 1011*5088Sab196087 ELFEDIT_I18NHDL(MSG_A2_DESC_SH_INFO), 1012*5088Sab196087 ELFEDIT_CMDOA_F_OPT }, 1013*5088Sab196087 { NULL } 1014*5088Sab196087 }; 1015*5088Sab196087 1016*5088Sab196087 /* shdr:sh_link */ 1017*5088Sab196087 static const char *name_sh_link[] = { 1018*5088Sab196087 MSG_ORIG(MSG_CMD_SH_LINK), NULL }; 1019*5088Sab196087 static elfedit_cmd_optarg_t arg_sh_link[] = { 1020*5088Sab196087 { MSG_ORIG(MSG_STR_SEC), 1021*5088Sab196087 /* MSG_INTL(MSG_A1_SEC) */ 1022*5088Sab196087 ELFEDIT_I18NHDL(MSG_A1_SEC), 1023*5088Sab196087 ELFEDIT_CMDOA_F_OPT }, 1024*5088Sab196087 { MSG_ORIG(MSG_STR_VALUE), 1025*5088Sab196087 /* MSG_INTL(MSG_A2_DESC_SH_LINK) */ 1026*5088Sab196087 ELFEDIT_I18NHDL(MSG_A2_DESC_SH_LINK), 1027*5088Sab196087 ELFEDIT_CMDOA_F_OPT }, 1028*5088Sab196087 { NULL } 1029*5088Sab196087 }; 1030*5088Sab196087 1031*5088Sab196087 /* shdr:sh_name */ 1032*5088Sab196087 static const char *name_sh_name[] = { 1033*5088Sab196087 MSG_ORIG(MSG_CMD_SH_NAME), NULL }; 1034*5088Sab196087 static elfedit_cmd_optarg_t opt_sh_name[] = { 1035*5088Sab196087 { MSG_ORIG(MSG_STR_MINUS_NAME_OFFSET), 1036*5088Sab196087 /* MSG_INTL(MSG_OPTDESC_NAME_OFFSET) */ 1037*5088Sab196087 ELFEDIT_I18NHDL(MSG_OPTDESC_NAME_OFFSET), 0, 1038*5088Sab196087 SHDR_OPT_F_NAMOFFSET, 0 }, 1039*5088Sab196087 { ELFEDIT_STDOA_OPT_O, NULL, 1040*5088Sab196087 ELFEDIT_CMDOA_F_INHERIT, 0, 0 }, 1041*5088Sab196087 { MSG_ORIG(MSG_STR_MINUS_SHNDX), 1042*5088Sab196087 /* MSG_INTL(MSG_OPTDESC_SHNDX) */ 1043*5088Sab196087 ELFEDIT_I18NHDL(MSG_OPTDESC_SHNDX), 0, 1044*5088Sab196087 SHDR_OPT_F_SHNDX, SHDR_OPT_F_SHTYP }, 1045*5088Sab196087 { MSG_ORIG(MSG_STR_MINUS_SHTYP), 1046*5088Sab196087 /* MSG_INTL(MSG_OPTDESC_SHTYP) */ 1047*5088Sab196087 ELFEDIT_I18NHDL(MSG_OPTDESC_SHTYP), 0, 1048*5088Sab196087 SHDR_OPT_F_SHTYP, SHDR_OPT_F_SHNDX }, 1049*5088Sab196087 { NULL } 1050*5088Sab196087 }; 1051*5088Sab196087 static elfedit_cmd_optarg_t arg_sh_name[] = { 1052*5088Sab196087 { MSG_ORIG(MSG_STR_SEC), 1053*5088Sab196087 /* MSG_INTL(MSG_A1_SEC) */ 1054*5088Sab196087 ELFEDIT_I18NHDL(MSG_A1_SEC), 1055*5088Sab196087 ELFEDIT_CMDOA_F_OPT }, 1056*5088Sab196087 { MSG_ORIG(MSG_STR_NAME), 1057*5088Sab196087 /* MSG_INTL(MSG_A2_DESC_SH_NAME) */ 1058*5088Sab196087 ELFEDIT_I18NHDL(MSG_A2_DESC_SH_NAME), 1059*5088Sab196087 ELFEDIT_CMDOA_F_OPT }, 1060*5088Sab196087 { NULL } 1061*5088Sab196087 }; 1062*5088Sab196087 1063*5088Sab196087 /* shdr:sh_offset */ 1064*5088Sab196087 static const char *name_sh_offset[] = { 1065*5088Sab196087 MSG_ORIG(MSG_CMD_SH_OFFSET), NULL }; 1066*5088Sab196087 static elfedit_cmd_optarg_t arg_sh_offset[] = { 1067*5088Sab196087 { MSG_ORIG(MSG_STR_SEC), 1068*5088Sab196087 /* MSG_INTL(MSG_A1_SEC) */ 1069*5088Sab196087 ELFEDIT_I18NHDL(MSG_A1_SEC), 1070*5088Sab196087 ELFEDIT_CMDOA_F_OPT }, 1071*5088Sab196087 { MSG_ORIG(MSG_STR_VALUE), 1072*5088Sab196087 /* MSG_INTL(MSG_A2_DESC_SH_OFFSET) */ 1073*5088Sab196087 ELFEDIT_I18NHDL(MSG_A2_DESC_SH_OFFSET), 1074*5088Sab196087 ELFEDIT_CMDOA_F_OPT }, 1075*5088Sab196087 { NULL } 1076*5088Sab196087 }; 1077*5088Sab196087 1078*5088Sab196087 /* shdr:sh_size */ 1079*5088Sab196087 static const char *name_sh_size[] = { 1080*5088Sab196087 MSG_ORIG(MSG_CMD_SH_SIZE), NULL }; 1081*5088Sab196087 static elfedit_cmd_optarg_t arg_sh_size[] = { 1082*5088Sab196087 { MSG_ORIG(MSG_STR_SEC), 1083*5088Sab196087 /* MSG_INTL(MSG_A1_SEC) */ 1084*5088Sab196087 ELFEDIT_I18NHDL(MSG_A1_SEC), 1085*5088Sab196087 ELFEDIT_CMDOA_F_OPT }, 1086*5088Sab196087 { MSG_ORIG(MSG_STR_VALUE), 1087*5088Sab196087 /* MSG_INTL(MSG_A2_DESC_SH_SIZE) */ 1088*5088Sab196087 ELFEDIT_I18NHDL(MSG_A2_DESC_SH_SIZE), 1089*5088Sab196087 ELFEDIT_CMDOA_F_OPT }, 1090*5088Sab196087 { NULL } 1091*5088Sab196087 }; 1092*5088Sab196087 1093*5088Sab196087 /* shdr:sh_type */ 1094*5088Sab196087 static const char *name_sh_type[] = { 1095*5088Sab196087 MSG_ORIG(MSG_CMD_SH_TYPE), NULL }; 1096*5088Sab196087 static elfedit_cmd_optarg_t arg_sh_type[] = { 1097*5088Sab196087 { MSG_ORIG(MSG_STR_SEC), 1098*5088Sab196087 /* MSG_INTL(MSG_A1_SEC) */ 1099*5088Sab196087 ELFEDIT_I18NHDL(MSG_A1_SEC), 1100*5088Sab196087 ELFEDIT_CMDOA_F_OPT }, 1101*5088Sab196087 { MSG_ORIG(MSG_STR_VALUE), 1102*5088Sab196087 /* MSG_INTL(MSG_A2_DESC_SH_TYPE) */ 1103*5088Sab196087 ELFEDIT_I18NHDL(MSG_A2_DESC_SH_TYPE), 1104*5088Sab196087 ELFEDIT_CMDOA_F_OPT }, 1105*5088Sab196087 { NULL } 1106*5088Sab196087 }; 1107*5088Sab196087 1108*5088Sab196087 static elfedit_cmd_t cmds[] = { 1109*5088Sab196087 /* shdr:dump */ 1110*5088Sab196087 { cmd_dump, cpl_1starg_sec, name_dump, 1111*5088Sab196087 /* MSG_INTL(MSG_DESC_DUMP) */ 1112*5088Sab196087 ELFEDIT_I18NHDL(MSG_DESC_DUMP), 1113*5088Sab196087 /* MSG_INTL(MSG_HELP_DUMP) */ 1114*5088Sab196087 ELFEDIT_I18NHDL(MSG_HELP_DUMP), 1115*5088Sab196087 opt_dump, arg_dump }, 1116*5088Sab196087 1117*5088Sab196087 /* shdr:sh_addr */ 1118*5088Sab196087 { cmd_sh_addr, cpl_1starg_sec, name_sh_addr, 1119*5088Sab196087 /* MSG_INTL(MSG_DESC_SH_ADDR) */ 1120*5088Sab196087 ELFEDIT_I18NHDL(MSG_DESC_SH_ADDR), 1121*5088Sab196087 /* MSG_INTL(MSG_HELP_SH_ADDR) */ 1122*5088Sab196087 ELFEDIT_I18NHDL(MSG_HELP_SH_ADDR), 1123*5088Sab196087 opt_std, arg_sh_addr }, 1124*5088Sab196087 1125*5088Sab196087 /* shdr:sh_addralign */ 1126*5088Sab196087 { cmd_sh_addralign, cpl_1starg_sec, name_sh_addralign, 1127*5088Sab196087 /* MSG_INTL(MSG_DESC_SH_ADDRALIGN) */ 1128*5088Sab196087 ELFEDIT_I18NHDL(MSG_DESC_SH_ADDRALIGN), 1129*5088Sab196087 /* MSG_INTL(MSG_HELP_SH_ADDRALIGN) */ 1130*5088Sab196087 ELFEDIT_I18NHDL(MSG_HELP_SH_ADDRALIGN), 1131*5088Sab196087 opt_std, arg_sh_addralign }, 1132*5088Sab196087 1133*5088Sab196087 /* shdr:sh_entsize */ 1134*5088Sab196087 { cmd_sh_entsize, cpl_1starg_sec, name_sh_entsize, 1135*5088Sab196087 /* MSG_INTL(MSG_DESC_SH_ENTSIZE) */ 1136*5088Sab196087 ELFEDIT_I18NHDL(MSG_DESC_SH_ENTSIZE), 1137*5088Sab196087 /* MSG_INTL(MSG_HELP_SH_ENTSIZE) */ 1138*5088Sab196087 ELFEDIT_I18NHDL(MSG_HELP_SH_ENTSIZE), 1139*5088Sab196087 opt_std, arg_sh_entsize }, 1140*5088Sab196087 1141*5088Sab196087 /* shdr:sh_flags */ 1142*5088Sab196087 { cmd_sh_flags, cpl_sh_flags, name_sh_flags, 1143*5088Sab196087 /* MSG_INTL(MSG_DESC_SH_FLAGS) */ 1144*5088Sab196087 ELFEDIT_I18NHDL(MSG_DESC_SH_FLAGS), 1145*5088Sab196087 /* MSG_INTL(MSG_HELP_SH_FLAGS) */ 1146*5088Sab196087 ELFEDIT_I18NHDL(MSG_HELP_SH_FLAGS), 1147*5088Sab196087 opt_sh_flags, arg_sh_flags }, 1148*5088Sab196087 1149*5088Sab196087 /* shdr:sh_info */ 1150*5088Sab196087 { cmd_sh_info, cpl_1starg_sec, name_sh_info, 1151*5088Sab196087 /* MSG_INTL(MSG_DESC_SH_INFO) */ 1152*5088Sab196087 ELFEDIT_I18NHDL(MSG_DESC_SH_INFO), 1153*5088Sab196087 /* MSG_INTL(MSG_HELP_SH_INFO) */ 1154*5088Sab196087 ELFEDIT_I18NHDL(MSG_HELP_SH_INFO), 1155*5088Sab196087 opt_std, arg_sh_info }, 1156*5088Sab196087 1157*5088Sab196087 /* shdr:sh_link */ 1158*5088Sab196087 { cmd_sh_link, cpl_1starg_sec, name_sh_link, 1159*5088Sab196087 /* MSG_INTL(MSG_DESC_SH_LINK) */ 1160*5088Sab196087 ELFEDIT_I18NHDL(MSG_DESC_SH_LINK), 1161*5088Sab196087 /* MSG_INTL(MSG_HELP_SH_LINK) */ 1162*5088Sab196087 ELFEDIT_I18NHDL(MSG_HELP_SH_LINK), 1163*5088Sab196087 opt_std, arg_sh_link }, 1164*5088Sab196087 1165*5088Sab196087 /* shdr:sh_name */ 1166*5088Sab196087 { cmd_sh_name, cpl_1starg_sec, name_sh_name, 1167*5088Sab196087 /* MSG_INTL(MSG_DESC_SH_NAME) */ 1168*5088Sab196087 ELFEDIT_I18NHDL(MSG_DESC_SH_NAME), 1169*5088Sab196087 /* MSG_INTL(MSG_HELP_SH_NAME) */ 1170*5088Sab196087 ELFEDIT_I18NHDL(MSG_HELP_SH_NAME), 1171*5088Sab196087 opt_sh_name, arg_sh_name }, 1172*5088Sab196087 1173*5088Sab196087 /* shdr:sh_offset */ 1174*5088Sab196087 { cmd_sh_offset, cpl_1starg_sec, name_sh_offset, 1175*5088Sab196087 /* MSG_INTL(MSG_DESC_SH_OFFSET) */ 1176*5088Sab196087 ELFEDIT_I18NHDL(MSG_DESC_SH_OFFSET), 1177*5088Sab196087 /* MSG_INTL(MSG_HELP_SH_OFFSET) */ 1178*5088Sab196087 ELFEDIT_I18NHDL(MSG_HELP_SH_OFFSET), 1179*5088Sab196087 opt_std, arg_sh_offset }, 1180*5088Sab196087 1181*5088Sab196087 /* shdr:sh_size */ 1182*5088Sab196087 { cmd_sh_size, cpl_1starg_sec, name_sh_size, 1183*5088Sab196087 /* MSG_INTL(MSG_DESC_SH_SIZE) */ 1184*5088Sab196087 ELFEDIT_I18NHDL(MSG_DESC_SH_SIZE), 1185*5088Sab196087 /* MSG_INTL(MSG_HELP_SH_SIZE) */ 1186*5088Sab196087 ELFEDIT_I18NHDL(MSG_HELP_SH_SIZE), 1187*5088Sab196087 opt_std, arg_sh_size }, 1188*5088Sab196087 1189*5088Sab196087 /* shdr:sh_type */ 1190*5088Sab196087 { cmd_sh_type, cpl_sh_type, name_sh_type, 1191*5088Sab196087 /* MSG_INTL(MSG_DESC_SH_TYPE) */ 1192*5088Sab196087 ELFEDIT_I18NHDL(MSG_DESC_SH_TYPE), 1193*5088Sab196087 /* MSG_INTL(MSG_HELP_SH_TYPE) */ 1194*5088Sab196087 ELFEDIT_I18NHDL(MSG_HELP_SH_TYPE), 1195*5088Sab196087 opt_std, arg_sh_type }, 1196*5088Sab196087 1197*5088Sab196087 { NULL } 1198*5088Sab196087 }; 1199*5088Sab196087 1200*5088Sab196087 static elfedit_module_t module = { 1201*5088Sab196087 ELFEDIT_VER_CURRENT, MSG_ORIG(MSG_MOD_NAME), 1202*5088Sab196087 /* MSG_INTL(MSG_MOD_DESC) */ 1203*5088Sab196087 ELFEDIT_I18NHDL(MSG_MOD_DESC), 1204*5088Sab196087 cmds, mod_i18nhdl_to_str }; 1205*5088Sab196087 1206*5088Sab196087 return (&module); 1207*5088Sab196087 } 1208