// File: /workspace/github_c_makefile_star2_O0/deplinenoise[P]vlink/targets.c
// Function: reenter_global_objsyms
void reenter_global_objsyms(struct GlobalVars *gv,struct ObjectUnit *ou)
/* Check all global symbols of an object unit against the global symbol
   table for redefinitions or common symbols.
   This is required when a new unit has been pulled into the linking
   process to resolve an undefined reference. */
{
  int i;

  for (i=0; i<OBJSYMHTABSIZE; i++) {
    struct Symbol *sym = ou->objsyms[i];

    while (sym) {
      if (sym->bind==SYMB_GLOBAL) {
        struct Symbol **chain = &gv->symbols[elf_hash(sym->name)%SYMHTABSIZE];
        struct Symbol *gsym;

        while (gsym = *chain) {
          if (!strcmp(sym->name,gsym->name))
            break;
          chain = &gsym->glob_chain;
        }

        if (gsym!=NULL && gsym!=sym) {
          if (sym->type==SYM_COMMON && gsym->type==SYM_COMMON) {
            if ((sym->size>gsym->size && sym->value>=gsym->value) ||
                (sym->size>=gsym->size && sym->value>gsym->value)) {
              /* replace by common symbol with bigger size or alignment */
              sym->glob_chain = gsym->glob_chain;
              remove_obj_symbol(gsym);  /* delete old symbol in object unit */
              *chain = sym;
            }
          }
          else {
            if (ou->lnkfile->type < ID_SHAREDOBJ)  {
              /* Global symbol "x" is already defined in... */
              error(19,ou->lnkfile->pathname,sym->name,getobjname(ou),
                    getobjname(gsym->relsect->obj));
            }
            #if 0
            /* This causes problems when using the same symbols for different
               CPUs, as with WarpOS/68k mixed-binaries (target amigaehf) */
            else {
              /* hide library symbol by replacing its name by:
                 __<object unit name>__<symbol name> */
              char buf[10];
              char *oname,*newname;

              if (ou->objname == NULL) {
                sprintf(buf,"o%08lx",(unsigned long)ou);
                oname = buf;
              }
              else
                oname = ou->objname;
              newname = alloc(strlen(oname) + strlen(sym->name) + 5);
              sprintf(newname,"__%s__%s",oname,sym->name);
              sym->name = newname;
            }
            #endif
          }
        }
      }
      sym = sym->obj_chain;
    }
  }
}

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x50(%rsp)
movq %rsi, 0x48(%rsp)
movl $0x0, 0x44(%rsp)
cmpl $0x20, 0x44(%rsp)
jge 0x10840
movq 0x48(%rsp), %rax
movq 0x48(%rax), %rax
movslq 0x44(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x38(%rsp)
cmpq $0x0, 0x38(%rsp)
je 0x1082e
movq 0x38(%rsp), %rax
movzbl 0x43(%rax), %eax
cmpl $0x2, %eax
jne 0x1081b
movq 0x50(%rsp), %rax
movq 0x180(%rax), %rax
movq %rax, 0x20(%rsp)
movq 0x38(%rsp), %rax
movq 0x20(%rax), %rdi
callq 0x8760
movq %rax, %rcx
movq 0x20(%rsp), %rax
andq $0xffff, %rcx           # imm = 0xFFFF
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x28(%rsp)
cmpq $0x0, %rax
je 0x106f1
movq 0x38(%rsp), %rax
movq 0x20(%rax), %rdi
movq 0x28(%rsp), %rax
movq 0x20(%rax), %rsi
callq 0x5130
cmpl $0x0, %eax
jne 0x106e1
jmp 0x106f1
movq 0x28(%rsp), %rax
addq $0x10, %rax
movq %rax, 0x30(%rsp)
jmp 0x106b0
cmpq $0x0, 0x28(%rsp)
je 0x10819
movq 0x28(%rsp), %rax
cmpq 0x38(%rsp), %rax
je 0x10819
movq 0x38(%rsp), %rax
movzbl 0x40(%rax), %eax
cmpl $0x3, %eax
jne 0x107a4
movq 0x28(%rsp), %rax
movzbl 0x40(%rax), %eax
cmpl $0x3, %eax
jne 0x107a4
movq 0x38(%rsp), %rax
movl 0x44(%rax), %eax
movq 0x28(%rsp), %rcx
cmpl 0x44(%rcx), %eax
jbe 0x10753
movq 0x38(%rsp), %rax
movq 0x30(%rax), %rax
movq 0x28(%rsp), %rcx
cmpq 0x30(%rcx), %rax
jge 0x10779
movq 0x38(%rsp), %rax
movl 0x44(%rax), %eax
movq 0x28(%rsp), %rcx
cmpl 0x44(%rcx), %eax
jb 0x107a2
movq 0x38(%rsp), %rax
movq 0x30(%rax), %rax
movq 0x28(%rsp), %rcx
cmpq 0x30(%rcx), %rax
jle 0x107a2
movq 0x28(%rsp), %rax
movq 0x10(%rax), %rcx
movq 0x38(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x28(%rsp), %rdi
callq 0xfc30
movq 0x38(%rsp), %rcx
movq 0x30(%rsp), %rax
movq %rcx, (%rax)
jmp 0x10817
movq 0x48(%rsp), %rax
movq 0x10(%rax), %rax
movzbl 0x39(%rax), %eax
cmpl $0x4, %eax
jge 0x10815
movq 0x48(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x10(%rax), %rax
movq %rax, 0x8(%rsp)
movq 0x38(%rsp), %rax
movq 0x20(%rax), %rax
movq %rax, 0x10(%rsp)
movq 0x48(%rsp), %rdi
callq 0x8f00
movq %rax, 0x18(%rsp)
movq 0x28(%rsp), %rax
movq 0x38(%rax), %rax
movq 0x10(%rax), %rdi
callq 0x8f00
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0x18(%rsp), %rcx
movq %rax, %r8
movl $0x13, %edi
movb $0x0, %al
callq 0x8c00
jmp 0x10817
jmp 0x10819
jmp 0x1081b
movq 0x38(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x38(%rsp)
jmp 0x10658
jmp 0x10830
movl 0x44(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x44(%rsp)
jmp 0x10636
addq $0x58, %rsp
retq
nopw %cs:(%rax,%rax)