// File: /workspace/github_c_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbp
movq %rdi, %r14
xorl %eax, %eax
cmpq $0x20, %rax
je 0xabdd
movq %rax, 0x8(%rsp)
leaq (,%rax,8), %rbx
addq 0x48(%rbp), %rbx
movq (%rbx), %rbx
testq %rbx, %rbx
je 0xabd0
cmpb $0x2, 0x43(%rbx)
jne 0xabc7
movq 0x180(%r14), %r15
movq 0x20(%rbx), %rdi
callq 0x69ee
movzwl %ax, %eax
leaq (%r15,%rax,8), %r13
movq (%r13), %r15
testq %r15, %r15
je 0xabc7
movq 0x20(%rbx), %r12
movq 0x20(%r15), %rsi
movq %r12, %rdi
callq 0x5160
testl %eax, %eax
je 0xab2f
addq $0x10, %r15
movq %r15, %r13
jmp 0xab05
cmpq %rbx, %r15
je 0xabc7
cmpb $0x3, 0x40(%rbx)
jne 0xab7e
cmpb $0x3, 0x40(%r15)
jne 0xab7e
movl 0x44(%rbx), %eax
movl 0x44(%r15), %ecx
cmpl %ecx, %eax
jbe 0xab5a
movq 0x30(%rbx), %rdx
cmpq 0x30(%r15), %rdx
jge 0xab68
cmpl %ecx, %eax
jb 0xabc7
movq 0x30(%rbx), %rax
cmpq 0x30(%r15), %rax
jle 0xabc7
movq 0x10(%r15), %rax
movq %rax, 0x10(%rbx)
movq %r15, %rdi
callq 0xa579
movq %rbx, (%r13)
jmp 0xabc7
movq 0x10(%rbp), %rax
cmpb $0x3, 0x39(%rax)
ja 0xabc7
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
movq %rbp, %rdi
callq 0x6e1c
movq %rbp, %r13
movq %rax, %rbp
movq 0x38(%r15), %rax
movq 0x10(%rax), %rdi
callq 0x6e1c
pushq $0x13
popq %rdi
movq 0x10(%rsp), %rsi
movq %r12, %rdx
movq %rbp, %rcx
movq %r13, %rbp
movq %rax, %r8
xorl %eax, %eax
callq 0x6c19
addq $0x18, %rbx
jmp 0xaad8
movq 0x8(%rsp), %rax
incq %rax
jmp 0xaabd
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq