+/* Add symbol SYM to the minimal symbol table of OBJFILE. */
+
+static void
+macho_symtab_add_minsym (struct objfile *objfile, const asymbol *sym)
+{
+ if (sym->name == NULL || *sym->name == '\0')
+ {
+ /* Skip names that don't exist (shouldn't happen), or names
+ that are null strings (may happen). */
+ return;
+ }
+
+ if (sym->flags & (BSF_GLOBAL | BSF_LOCAL | BSF_WEAK))
+ {
+ CORE_ADDR symaddr;
+ CORE_ADDR offset;
+ enum minimal_symbol_type ms_type;
+
+ offset = ANOFFSET (objfile->section_offsets, sym->section->index);
+
+ /* Bfd symbols are section relative. */
+ symaddr = sym->value + sym->section->vma;
+
+ /* Select global/local/weak symbols. Note that bfd puts abs
+ symbols in their own section, so all symbols we are
+ interested in will have a section. */
+ /* Relocate all non-absolute and non-TLS symbols by the
+ section offset. */
+ if (sym->section != bfd_abs_section_ptr
+ && !(sym->section->flags & SEC_THREAD_LOCAL))
+ symaddr += offset;
+
+ if (sym->section == bfd_abs_section_ptr)
+ ms_type = mst_abs;
+ else if (sym->section->flags & SEC_CODE)
+ {
+ if (sym->flags & (BSF_GLOBAL | BSF_WEAK))
+ ms_type = mst_text;
+ else
+ ms_type = mst_file_text;
+ }
+ else if (sym->section->flags & SEC_ALLOC)
+ {
+ if (sym->flags & (BSF_GLOBAL | BSF_WEAK))
+ {
+ if (sym->section->flags & SEC_LOAD)
+ ms_type = mst_data;
+ else
+ ms_type = mst_bss;
+ }
+ else if (sym->flags & BSF_LOCAL)
+ {
+ /* Not a special stabs-in-elf symbol, do regular
+ symbol processing. */
+ if (sym->section->flags & SEC_LOAD)
+ ms_type = mst_file_data;
+ else
+ ms_type = mst_file_bss;
+ }
+ else
+ ms_type = mst_unknown;
+ }
+ else
+ return; /* Skip this symbol. */
+
+ prim_record_minimal_symbol_and_info
+ (sym->name, symaddr, ms_type, sym->section->index,
+ sym->section, objfile);
+ }
+}
+