// File: /workspace/github_c_makefile_star2_O2/deplinenoise[P]vlink/targets.c
// Function: addglobsym
bool addglobsym(struct GlobalVars *gv,struct Symbol *newsym)
/* insert symbol into global symbol hash table */
{
  struct Symbol **chain = &gv->symbols[elf_hash(newsym->name)%SYMHTABSIZE];
  struct Symbol *sym;
  struct ObjectUnit *newou = newsym->relsect ? newsym->relsect->obj : NULL;

  while (sym = *chain) {
    if (!strcmp(newsym->name,sym->name)) {

      if (newsym->type==SYM_ABS && sym->type==SYM_ABS &&
          newsym->value == sym->value)
        return FALSE;  /* absolute symbols with same value are ignored */

      if (newsym->relsect == NULL || sym->relsect == NULL) {
        /* redefined linker script symbol */
        if (newou!=NULL && newou->lnkfile->type<ID_LIBBASE) {
          static const char *objname = "ldscript";

          error(19,newou ? newou->lnkfile->pathname : objname,
                newsym->name, newou ? getobjname(newou) : objname,
                sym->relsect ? getobjname(sym->relsect->obj) : objname);
        }
        /* redefinitions in libraries are silently ignored */
        return FALSE;
      }

      if (sym->bind == SYMB_GLOBAL) {
        /* symbol already defined with global binding */

        if (newsym->bind == SYMB_GLOBAL) {
          if (newou->lnkfile->type < ID_LIBBASE) {
            if (newsym->type==SYM_COMMON && sym->type==SYM_COMMON) {
              if ((newsym->size>sym->size && newsym->value>=sym->value) ||
                  (newsym->size>=sym->size && newsym->value>sym->value)) {
                /* replace by common symbol with bigger size or alignment */
                newsym->glob_chain = sym->glob_chain;
                remove_obj_symbol(sym);  /* delete old symbol in object unit */
                break;
              }
            }
            else {
              /* Global symbol "x" is already defined in... */
              error(19,newou->lnkfile->pathname,newsym->name,
                    getobjname(newou),getobjname(sym->relsect->obj));
            }
            return FALSE;  /* ignore this symbol */
          }
          /* else: add global library symbol with same name to the chain -
             some targets may want to choose between them! */
        }
        else
          return FALSE;  /* don't replace global by nonglobal symbols */
      }

      else {
        if (newsym->bind == SYMB_WEAK)
          return FALSE;  /* don't replace weak by weak */

        /* replace weak symbol by a global one */
        newsym->glob_chain = sym->glob_chain;
        remove_obj_symbol(sym);  /* delete old symbol in object unit */
        break;
      }
    }

    chain = &sym->glob_chain;
  }

  *chain = newsym;
  if (newou) {
    if (trace_sym_access(gv,newsym->name))
      fprintf(stderr,"Symbol %s defined in section %s in %s\n",
              newsym->name,newsym->relsect->name,getobjname(newou));
  }
  return TRUE;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r14
movq %rdi, 0x8(%rsp)
movq 0x180(%rdi), %rbx
movq 0x20(%rsi), %rdi
callq 0x69ee
movzwl %ax, %eax
movq 0x38(%r14), %rcx
testq %rcx, %rcx
movq %rcx, 0x10(%rsp)
je 0xa36b
movq 0x10(%rcx), %rcx
movq %rcx, (%rsp)
jmp 0xa373
movq $0x0, (%rsp)
leaq (%rbx,%rax,8), %rbx
pushq $0x1
popq %r15
xorl %ebp, %ebp
movq (%rbx), %r12
testq %r12, %r12
je 0xa4ef
movq 0x20(%r14), %r13
movq 0x20(%r12), %rsi
movq %r13, %rdi
callq 0x5160
testl %eax, %eax
jne 0xa3f0
movb 0x40(%r14), %al
cmpb $0x1, %al
jne 0xa3bd
cmpb $0x1, 0x40(%r12)
jne 0xa3bd
movq 0x30(%r14), %rcx
cmpq 0x30(%r12), %rcx
je 0xa44a
cmpq $0x0, 0x10(%rsp)
je 0xa3f9
cmpq $0x0, 0x38(%r12)
je 0xa3f9
cmpb $0x2, 0x43(%r12)
movb 0x43(%r14), %cl
jne 0xa441
cmpb $0x2, %cl
jne 0xa52e
movq (%rsp), %rcx
movq 0x10(%rcx), %rcx
cmpb $0x3, 0x39(%rcx)
jbe 0xa451
addq $0x10, %r12
movq %r12, %rbx
jmp 0xa37d
xorl %ebp, %ebp
movq (%rsp), %rdi
testq %rdi, %rdi
je 0xa52e
movq 0x10(%rdi), %rax
cmpb $0x3, 0x39(%rax)
ja 0xa52e
movq 0x10(%rax), %r14
callq 0x6e1c
movq %rax, %rbx
movq 0x38(%r12), %rax
testq %rax, %rax
je 0xa512
movq 0x10(%rax), %rdi
callq 0x6e1c
movq %rax, %r8
jmp 0xa519
cmpb $0x3, %cl
jne 0xa4de
xorl %ebp, %ebp
jmp 0xa52e
cmpb $0x3, %al
jne 0xa4ad
cmpb $0x3, 0x40(%r12)
jne 0xa4ad
movl 0x44(%r14), %eax
movl 0x44(%r12), %ecx
cmpl %ecx, %eax
movq (%rsp), %r13
jbe 0xa479
movq 0x30(%r14), %rdx
cmpq 0x30(%r12), %rdx
jge 0xa494
cmpl %ecx, %eax
jb 0xa52e
movq 0x30(%r14), %rax
cmpq 0x30(%r12), %rax
movq (%rsp), %r13
jle 0xa52e
movq 0x10(%r12), %rax
movq %rax, 0x10(%r14)
movq %r12, %rdi
callq 0xa579
movq %r14, (%rbx)
movq %r13, %rbx
jmp 0xa4fb
movq 0x10(%rcx), %r14
movq (%rsp), %rdi
callq 0x6e1c
movq %rax, %rbx
movq 0x38(%r12), %rax
movq 0x10(%rax), %rdi
callq 0x6e1c
xorl %ebp, %ebp
pushq $0x13
popq %rdi
movq %r14, %rsi
movq %r13, %rdx
movq %rbx, %rcx
movq %rax, %r8
jmp 0xa527
movq 0x10(%r12), %rax
movq %rax, 0x10(%r14)
movq %r12, %rdi
callq 0xa579
movq %r14, (%rbx)
movq (%rsp), %rbx
testq %rbx, %rbx
je 0xa50d
movq 0x20(%r14), %rsi
movq 0x8(%rsp), %rdi
callq 0x7039
testl %eax, %eax
jne 0xa53f
movl %r15d, %ebp
jmp 0xa52e
leaq 0x1620b(%rip), %r8      # 0x20724
xorl %ebp, %ebp
pushq $0x13
popq %rdi
movq %r14, %rsi
movq %r13, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x6c19
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x24aaa(%rip), %rax     # 0x2eff0
movq (%rax), %r13
movq 0x20(%r14), %r12
movq 0x38(%r14), %rax
movq 0x20(%rax), %r14
movq %rbx, %rdi
callq 0x6e1c
leaq 0x161c9(%rip), %rsi     # 0x2072d
movq %r13, %rdi
movq %r12, %rdx
movq %r14, %rcx
movq %rax, %r8
xorl %eax, %eax
callq 0x5180
jmp 0xa50d