998 default:
999 return (0);
1000 }
1001 default:
1002 return (0);
1003 }
1004 }
1005
1006 /*
1007 * If it comes here, any symbol can be printed.
1008 * (So basically, -f is no-op.)
1009 */
1010 return (1);
1011 }
1012
1013 #ifndef XPG4
1014 /*
1015 * -u flag specified
1016 */
1017 static void
1018 print_with_uflag(
1019 SYM *sym_data,
1020 char *filename
1021 )
1022 {
1023 if ((sym_data->shndx == SHN_UNDEF) && (strlen(sym_data->name))) {
1024 if (!r_flag) {
1025 if (R_flag) {
1026 if (archive_name != (char *)0)
1027 (void) printf(" %s:%s:%s\n",
1028 archive_name, filename,
1029 sym_data->name);
1030 else
1031 (void) printf(" %s:%s\n",
1032 filename, sym_data->name);
1033 }
1034 else
1035 (void) printf(" %s\n", sym_data->name);
1036 }
1037 else
1038 (void) printf(" %s:%s\n", filename, sym_data->name);
1039 }
1040 }
1041 #endif
1078 sym_key = lookup(sym_data->type, sym_data->bind);
1079 }
1080
1081 if (sym_key != NULL) {
1082 if (!l_flag)
1083 (void) printf("%c ", sym_key[0]);
1084 else
1085 (void) printf("%-3s", sym_key);
1086 } else {
1087 if (!l_flag)
1088 (void) printf("%-2d", sym_data->type);
1089 else
1090 (void) printf("%-3d", sym_data->type);
1091 }
1092 }
1093
1094 /*
1095 * -p flag specified
1096 */
1097 static void
1098 print_with_pflag(
1099 int ndigits,
1100 Elf *elf_file,
1101 unsigned int shstrndx,
1102 SYM *sym_data,
1103 char *filename
1104 )
1105 {
1106 const char * const fmt[] = {
1107 "%.*llu ", /* FMT_T_DEC */
1108 "0x%.*llx ", /* FMT_T_HEX */
1109 "0%.*llo " /* FMT_T_OCT */
1110 };
1111
1112 if (is_sym_print(sym_data) != 1)
1113 return;
1114 /*
1115 * -A header
1116 */
1117 if (A_flag != 0)
1118 (void) printf("%s", A_header);
1119
1120 /*
1121 * Symbol Value.
1122 * (hex/octal/decimal)
1123 */
1124 (void) printf(fmt[fmt_flag], ndigits, EC_ADDR(sym_data->value));
1132 if (!r_flag) {
1133 if (R_flag) {
1134 if (archive_name != (char *)0)
1135 (void) printf("%s:%s:%s\n", archive_name,
1136 filename, sym_data->name);
1137 else
1138 (void) printf("%s:%s\n", filename,
1139 sym_data->name);
1140 }
1141 else
1142 (void) printf("%s\n", sym_data->name);
1143 }
1144 else
1145 (void) printf("%s:%s\n", filename, sym_data->name);
1146 }
1147
1148 /*
1149 * -P flag specified
1150 */
1151 static void
1152 print_with_Pflag(
1153 int ndigits,
1154 Elf *elf_file,
1155 unsigned int shstrndx,
1156 SYM *sym_data
1157 )
1158 {
1159 #define SYM_LEN 10
1160 char sym_name[SYM_LEN+1];
1161 size_t len;
1162 const char * const fmt[] = {
1163 "%*llu %*llu \n", /* FMT_T_DEC */
1164 "%*llx %*llx \n", /* FMT_T_HEX */
1165 "%*llo %*llo \n" /* FMT_T_OCT */
1166 };
1167
1168 if (is_sym_print(sym_data) != 1)
1169 return;
1170 /*
1171 * -A header
1172 */
1173 if (A_flag != 0)
1174 (void) printf("%s", A_header);
1175
1176 /*
1177 * Symbol name
1184 (void) printf("%s ", sym_name);
1185 }
1186
1187 /*
1188 * Symbol Type.
1189 */
1190 print_brief_sym_type(elf_file, shstrndx, sym_data);
1191
1192 /*
1193 * Symbol Value & size
1194 * (hex/octal/decimal)
1195 */
1196 (void) printf(fmt[fmt_flag], ndigits, EC_ADDR(sym_data->value),
1197 ndigits, EC_XWORD(sym_data->size));
1198 }
1199
1200 /*
1201 * other flags specified
1202 */
1203 static void
1204 print_with_otherflags(
1205 int ndigits,
1206 Elf *elf_file,
1207 unsigned int shstrndx,
1208 SYM *sym_data,
1209 char *filename
1210 )
1211 {
1212 const char * const fmt_value_size[] = {
1213 "%*llu|%*lld|", /* FMT_T_DEC */
1214 "0x%.*llx|0x%.*llx|", /* FMT_T_HEX */
1215 "0%.*llo|0%.*llo|" /* FMT_T_OCT */
1216 };
1217 const char * const fmt_int[] = {
1218 "%-5d", /* FMT_T_DEC */
1219 "%#-5x", /* FMT_T_HEX */
1220 "%#-5o" /* FMT_T_OCT */
1221 };
1222
1223 if (is_sym_print(sym_data) != 1)
1224 return;
1225 (void) printf("%s", A_header);
1226 (void) printf("[%d]\t|", sym_data->indx);
1227 (void) printf(fmt_value_size[fmt_flag], ndigits,
1228 EC_ADDR(sym_data->value), ndigits, EC_XWORD(sym_data->size));
1229
1230 switch (sym_data->type) {
|
998 default:
999 return (0);
1000 }
1001 default:
1002 return (0);
1003 }
1004 }
1005
1006 /*
1007 * If it comes here, any symbol can be printed.
1008 * (So basically, -f is no-op.)
1009 */
1010 return (1);
1011 }
1012
1013 #ifndef XPG4
1014 /*
1015 * -u flag specified
1016 */
1017 static void
1018 print_with_uflag(SYM *sym_data, char *filename)
1019 {
1020 if ((sym_data->shndx == SHN_UNDEF) && (strlen(sym_data->name))) {
1021 if (!r_flag) {
1022 if (R_flag) {
1023 if (archive_name != (char *)0)
1024 (void) printf(" %s:%s:%s\n",
1025 archive_name, filename,
1026 sym_data->name);
1027 else
1028 (void) printf(" %s:%s\n",
1029 filename, sym_data->name);
1030 }
1031 else
1032 (void) printf(" %s\n", sym_data->name);
1033 }
1034 else
1035 (void) printf(" %s:%s\n", filename, sym_data->name);
1036 }
1037 }
1038 #endif
1075 sym_key = lookup(sym_data->type, sym_data->bind);
1076 }
1077
1078 if (sym_key != NULL) {
1079 if (!l_flag)
1080 (void) printf("%c ", sym_key[0]);
1081 else
1082 (void) printf("%-3s", sym_key);
1083 } else {
1084 if (!l_flag)
1085 (void) printf("%-2d", sym_data->type);
1086 else
1087 (void) printf("%-3d", sym_data->type);
1088 }
1089 }
1090
1091 /*
1092 * -p flag specified
1093 */
1094 static void
1095 print_with_pflag(int ndigits, Elf *elf_file, unsigned int shstrndx,
1096 SYM *sym_data, char *filename)
1097 {
1098 const char * const fmt[] = {
1099 "%.*llu ", /* FMT_T_DEC */
1100 "0x%.*llx ", /* FMT_T_HEX */
1101 "0%.*llo " /* FMT_T_OCT */
1102 };
1103
1104 if (is_sym_print(sym_data) != 1)
1105 return;
1106 /*
1107 * -A header
1108 */
1109 if (A_flag != 0)
1110 (void) printf("%s", A_header);
1111
1112 /*
1113 * Symbol Value.
1114 * (hex/octal/decimal)
1115 */
1116 (void) printf(fmt[fmt_flag], ndigits, EC_ADDR(sym_data->value));
1124 if (!r_flag) {
1125 if (R_flag) {
1126 if (archive_name != (char *)0)
1127 (void) printf("%s:%s:%s\n", archive_name,
1128 filename, sym_data->name);
1129 else
1130 (void) printf("%s:%s\n", filename,
1131 sym_data->name);
1132 }
1133 else
1134 (void) printf("%s\n", sym_data->name);
1135 }
1136 else
1137 (void) printf("%s:%s\n", filename, sym_data->name);
1138 }
1139
1140 /*
1141 * -P flag specified
1142 */
1143 static void
1144 print_with_Pflag(int ndigits, Elf *elf_file, unsigned int shstrndx,
1145 SYM *sym_data)
1146 {
1147 #define SYM_LEN 10
1148 char sym_name[SYM_LEN+1];
1149 size_t len;
1150 const char * const fmt[] = {
1151 "%*llu %*llu \n", /* FMT_T_DEC */
1152 "%*llx %*llx \n", /* FMT_T_HEX */
1153 "%*llo %*llo \n" /* FMT_T_OCT */
1154 };
1155
1156 if (is_sym_print(sym_data) != 1)
1157 return;
1158 /*
1159 * -A header
1160 */
1161 if (A_flag != 0)
1162 (void) printf("%s", A_header);
1163
1164 /*
1165 * Symbol name
1172 (void) printf("%s ", sym_name);
1173 }
1174
1175 /*
1176 * Symbol Type.
1177 */
1178 print_brief_sym_type(elf_file, shstrndx, sym_data);
1179
1180 /*
1181 * Symbol Value & size
1182 * (hex/octal/decimal)
1183 */
1184 (void) printf(fmt[fmt_flag], ndigits, EC_ADDR(sym_data->value),
1185 ndigits, EC_XWORD(sym_data->size));
1186 }
1187
1188 /*
1189 * other flags specified
1190 */
1191 static void
1192 print_with_otherflags(int ndigits, Elf *elf_file, unsigned int shstrndx,
1193 SYM *sym_data, char *filename)
1194 {
1195 const char * const fmt_value_size[] = {
1196 "%*llu|%*lld|", /* FMT_T_DEC */
1197 "0x%.*llx|0x%.*llx|", /* FMT_T_HEX */
1198 "0%.*llo|0%.*llo|" /* FMT_T_OCT */
1199 };
1200 const char * const fmt_int[] = {
1201 "%-5d", /* FMT_T_DEC */
1202 "%#-5x", /* FMT_T_HEX */
1203 "%#-5o" /* FMT_T_OCT */
1204 };
1205
1206 if (is_sym_print(sym_data) != 1)
1207 return;
1208 (void) printf("%s", A_header);
1209 (void) printf("[%d]\t|", sym_data->indx);
1210 (void) printf(fmt_value_size[fmt_flag], ndigits,
1211 EC_ADDR(sym_data->value), ndigits, EC_XWORD(sym_data->size));
1212
1213 switch (sym_data->type) {
|