static void obj_mach_o_weak (int ignore ATTRIBUTE_UNUSED) { char *name; int c; symbolS *symbolP; do { /* Get symbol name. */ name = input_line_pointer; c = get_symbol_end (); symbolP = symbol_find_or_make (name); S_SET_WEAK (symbolP); *input_line_pointer = c; SKIP_WHITESPACE (); if (c != ',') break; input_line_pointer++; SKIP_WHITESPACE (); } while (*input_line_pointer != '\n'); demand_empty_rest_of_line (); }
static void s_common() { register char *name; register char c; register char *p; register int temp; register symbolS * symbolP; name = input_line_pointer; c = get_symbol_end(); /* just after name is now '\0' */ p = input_line_pointer; *p = c; SKIP_WHITESPACE(); if ( * input_line_pointer != ',' ) { as_warn("Expected comma after symbol-name"); ignore_rest_of_line(); return; } input_line_pointer ++; /* skip ',' */ if ( (temp = get_absolute_expression ()) < 0 ) { as_warn(".COMMon length (%d.) <0! Ignored.", temp); ignore_rest_of_line(); return; } *p = 0; symbolP = symbol_find_or_make (name); *p = c; if ( (symbolP->sy_type & N_TYPE) != N_UNDF || symbolP->sy_other != 0 || symbolP->sy_desc != 0) { as_warn( "Ignoring attempt to re-define symbol"); ignore_rest_of_line(); return; } if (symbolP->sy_value) { if (symbolP->sy_value != temp) { as_warn( "Length of .comm \"%s\" is already %d. Not changed to %d.", symbolP->sy_name, symbolP->sy_value, temp); } } else { symbolP->sy_value = temp; symbolP->sy_type |= N_EXT; } know(symbolP->sy_frag == &zero_address_frag); if (strncmp(input_line_pointer, ",\"bss\"", 6) != 0) { p=input_line_pointer; while(*p && *p!='\n') p++; c= *p; *p='\0'; as_warn("bad .common segment: `%s'", input_line_pointer); *p=c; return; } input_line_pointer += 6; demand_empty_rest_of_line(); return; }
static void obj_coff_val (int ignore ATTRIBUTE_UNUSED) { if (def_symbol_in_progress == NULL) { as_warn (_(".val pseudo-op used outside of .def/.endef ignored.")); demand_empty_rest_of_line (); return; } if (is_name_beginner (*input_line_pointer)) { char *symbol_name = input_line_pointer; char name_end = get_symbol_end (); #ifdef tc_canonicalize_symbol_name symbol_name = tc_canonicalize_symbol_name (symbol_name); #endif if (streq (symbol_name, ".")) { /* If the .val is != from the .def (e.g. statics). */ symbol_set_frag (def_symbol_in_progress, frag_now); S_SET_VALUE (def_symbol_in_progress, (valueT) frag_now_fix ()); } else if (! streq (S_GET_NAME (def_symbol_in_progress), symbol_name)) { expressionS exp; exp.X_op = O_symbol; exp.X_add_symbol = symbol_find_or_make (symbol_name); exp.X_op_symbol = NULL; exp.X_add_number = 0; symbol_set_value_expression (def_symbol_in_progress, &exp); /* If the segment is undefined when the forward reference is resolved, then copy the segment id from the forward symbol. */ SF_SET_GET_SEGMENT (def_symbol_in_progress); /* FIXME: gcc can generate address expressions here in unusual cases (search for "obscure" in sdbout.c). We just ignore the offset here, thus generating incorrect debugging information. We ignore the rest of the line just below. */ } /* Otherwise, it is the name of a non debug symbol and its value will be calculated later. */ *input_line_pointer = name_end; } else { S_SET_VALUE (def_symbol_in_progress, get_absolute_expression ()); } demand_empty_rest_of_line (); }
/* * sort of like s_lcomm * */ static void s_reserve() { char *name; char c; char *p; int temp; symbolS *symbolP; name = input_line_pointer; c = get_symbol_end(); p = input_line_pointer; *p = c; SKIP_WHITESPACE(); if ( * input_line_pointer != ',' ) { as_warn("Expected comma after name"); ignore_rest_of_line(); return; } input_line_pointer ++; if ((temp = get_absolute_expression()) < 0) { as_warn("BSS length (%d.) <0! Ignored.", temp); ignore_rest_of_line(); return; } *p = 0; symbolP = symbol_find_or_make(name); *p = c; if (strncmp(input_line_pointer, ",\"bss\"", 6) != 0) { as_warn("bad .reserve segment: `%s'", input_line_pointer); return; } input_line_pointer += 6; if (symbolP->sy_other == 0 && symbolP->sy_desc == 0 && ((symbolP->sy_type == N_BSS && symbolP->sy_value == local_bss_counter) || ((symbolP->sy_type & N_TYPE) == N_UNDF && symbolP->sy_value == 0))) { symbolP->sy_value = local_bss_counter; symbolP->sy_type = N_BSS; symbolP->sy_frag = & bss_address_frag; local_bss_counter += temp; } else { as_warn( "Ignoring attempt to re-define symbol from %d. to %d.", symbolP->sy_value, local_bss_counter ); } demand_empty_rest_of_line(); return; }
void pecoff_obj_set_weak_hook (symbolS *symbolP) { symbolS *alternateP; /* See _Microsoft Portable Executable and Common Object File Format Specification_, section 5.5.3. Create a symbol representing the alternate value. coff_frob_symbol will set the value of this symbol from the value of the weak symbol itself. */ S_SET_STORAGE_CLASS (symbolP, C_NT_WEAK); S_SET_NUMBER_AUXILIARY (symbolP, 1); SA_SET_SYM_FSIZE (symbolP, IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY); alternateP = symbol_find_or_make (weak_name2altname (S_GET_NAME (symbolP))); S_SET_EXTERNAL (alternateP); S_SET_STORAGE_CLASS (alternateP, C_NT_WEAK); SA_SET_SYM_TAGNDX (symbolP, alternateP); }
static void obj_coff_weak (int ignore ATTRIBUTE_UNUSED) { char *name; int c; symbolS *symbolP; do { name = input_line_pointer; c = get_symbol_end (); if (*name == 0) { as_warn (_("badly formed .weak directive ignored")); ignore_rest_of_line (); return; } c = 0; symbolP = symbol_find_or_make (name); *input_line_pointer = c; SKIP_WHITESPACE (); S_SET_WEAK (symbolP); if (c == ',') { input_line_pointer++; SKIP_WHITESPACE (); if (*input_line_pointer == '\n') c = '\n'; } } while (c == ','); demand_empty_rest_of_line (); }
/* * layout_indirect_symbols() setups the indirect symbol tables by looking up or * creating symbol from the indirect symbol names and recording the symbol * pointers. It returns the total count of indirect symbol table entries. */ static uint32_t layout_indirect_symbols(void) { struct frchain *frchainP; uint32_t section_type, total, count, stride; isymbolS *isymbolP; symbolS *symbolP; /* * Mark symbols that only appear in a lazy section with * REFERENCE_FLAG_UNDEFINED_LAZY. To do this we first make sure a * symbol exists for all non-lazy symbols. Then we make a pass looking * up the lazy symbols and if not there we make the symbol and mark it * with REFERENCE_FLAG_UNDEFINED_LAZY. */ for(frchainP = frchain_root; frchainP; frchainP = frchainP->frch_next){ section_type = frchainP->frch_section.flags & SECTION_TYPE; if(section_type == S_NON_LAZY_SYMBOL_POINTERS){ for(isymbolP = frchainP->frch_isym_root; isymbolP != NULL; isymbolP = isymbolP->isy_next){ /* (void)symbol_find_or_make(isymbolP->isy_name); */ symbolP = symbol_find(isymbolP->isy_name); if(symbolP == NULL){ symbolP = symbol_new(isymbolP->isy_name, N_UNDF, 0, 0, 0, &zero_address_frag); symbol_table_insert(symbolP); } } } } for(frchainP = frchain_root; frchainP; frchainP = frchainP->frch_next){ section_type = frchainP->frch_section.flags & SECTION_TYPE; if(section_type == S_LAZY_SYMBOL_POINTERS || section_type == S_SYMBOL_STUBS){ for(isymbolP = frchainP->frch_isym_root; isymbolP != NULL; isymbolP = isymbolP->isy_next){ symbolP = symbol_find(isymbolP->isy_name); if(symbolP == NULL){ symbolP = symbol_find_or_make(isymbolP->isy_name); symbolP->sy_desc |= REFERENCE_FLAG_UNDEFINED_LAZY; } } } } total = 0; for(frchainP = frchain_root; frchainP; frchainP = frchainP->frch_next){ section_type = frchainP->frch_section.flags & SECTION_TYPE; if(section_type == S_LAZY_SYMBOL_POINTERS || section_type == S_NON_LAZY_SYMBOL_POINTERS || section_type == S_SYMBOL_STUBS){ count = 0; for(isymbolP = frchainP->frch_isym_root; isymbolP != NULL; isymbolP = isymbolP->isy_next){ /* symbolP = symbol_find_or_make(isymbolP->isy_name); */ symbolP = symbol_find(isymbolP->isy_name); if(symbolP == NULL){ symbolP = symbol_new(isymbolP->isy_name, N_UNDF, 0, 0, 0, &zero_address_frag); symbol_table_insert(symbolP); } isymbolP->isy_symbol = symbolP; count++; } /* * Check for missing indirect symbols. */ if(section_type == S_SYMBOL_STUBS) stride = frchainP->frch_section.reserved2; else stride = sizeof(signed_target_addr_t); if(frchainP->frch_section.size / stride != count) as_bad("missing indirect symbols for section (%s,%s)", frchainP->frch_section.segname, frchainP->frch_section.sectname); /* * Set the index into the indirect symbol table for this * section into the reserved1 field. */ frchainP->frch_section.reserved1 = total; total += count; } } return(total); }
static void nemaweaver_s_lcomm (int xxx ATTRIBUTE_UNUSED) { char *name; char c; char *p; offsetT size; symbolS *symbolP; offsetT align; char *pfrag; int align2; segT current_seg = now_seg; subsegT current_subseg = now_subseg; name = input_line_pointer; c = get_symbol_end (); /* Just after name is now '\0'. */ p = input_line_pointer; *p = c; SKIP_WHITESPACE (); if (*input_line_pointer != ',') { as_bad (_("Expected comma after symbol-name: rest of line ignored.")); ignore_rest_of_line (); return; } input_line_pointer++; /* skip ',' */ if ((size = get_absolute_expression ()) < 0) { as_warn (_(".COMMon length (%ld.) <0! Ignored."), (long) size); ignore_rest_of_line (); return; } /* The third argument to .lcomm is the alignment. */ if (*input_line_pointer != ',') align = 8; else { ++input_line_pointer; align = get_absolute_expression (); if (align <= 0) { as_warn (_("ignoring bad alignment")); align = 8; } } *p = 0; symbolP = symbol_find_or_make (name); *p = c; if (S_IS_DEFINED (symbolP) && ! S_IS_COMMON (symbolP)) { as_bad (_("Ignoring attempt to re-define symbol `%s'."), S_GET_NAME (symbolP)); ignore_rest_of_line (); return; } if (S_GET_VALUE (symbolP) && S_GET_VALUE (symbolP) != (valueT) size) { as_bad (_("Length of .lcomm \"%s\" is already %ld. Not changed to %ld."), S_GET_NAME (symbolP), (long) S_GET_VALUE (symbolP), (long) size); ignore_rest_of_line (); return; } /* Allocate_bss. */ if (align) { /* Convert to a power of 2 alignment. */ for (align2 = 0; (align & 1) == 0; align >>= 1, ++align2); if (align != 1) { as_bad (_("Common alignment not a power of 2")); ignore_rest_of_line (); return; } } else