// File: /workspace/github_c_makefile_star2_O1/deplinenoise[P]vlink/t_amigahunk.c
// Function: ehf_lnksym
static struct Symbol *ehf_lnksym(struct GlobalVars *gv,struct Section *sec,
                                 struct Reloc *xref)
/* Checks if undefined symbol is an EHF-linker symbol */
{
  if (!gv->dest_object) {

    if (!strncmp(ehf_addrsym,xref->xrefname,sizeof(ehf_addrsym)-1)) {
      const char *symname = xref->xrefname + (sizeof(ehf_addrsym) - 1);

      if (find_any_symbol(gv,sec,symname)) {
        /* Reference to an unknown symbol, which starts with "@_". */
        /* The symbol without "@_" has to exist. */
        char *objname = alloc(strlen(symname)+3);
        uint8_t *dat = alloczero(sizeof(uint32_t)); /* space for a 32-bit ptr */
        struct ObjectUnit *ou;
        struct Section *s;
        struct Symbol *sym;
        struct Reloc *r;

        /* create an artificial object with a ".tocd" data section */
        sprintf(objname,"%s.o",symname);
        ou = art_objunit(gv,objname,dat,sizeof(uint32_t));
        s = add_section(ou,".tocd",dat,sizeof(uint32_t),ST_DATA,
                        SF_ALLOC,SP_READ|SP_WRITE,2,FALSE);

        /* "@__name" contains a 32-bit reloc pointer, which has an */
        /* external reference to the symbol "_name". */
        r = newreloc(gv,s,symname,NULL,0,0,R_ABS,0);
        addreloc(s,r,0,32,-1);

        /* make "@__name" visible for the further linking process: */
        if (addsymbol(gv,s,xref->xrefname,NULL,0,SYM_RELOC,0,SYMI_OBJECT,
                      SYMB_GLOBAL,sizeof(uint32_t),FALSE))
          ierror("ehf_lnksym(): %s was assumed to be undefined, but "
                 "in reality it *is* defined",xref->xrefname);

        if (!(sym = findsymbol(gv,sec,xref->xrefname)))
          ierror("ehf_lnksym(): The just defined symbol %s has "
                 "disappeared",xref->xrefname);
        return (sym);
      }
    }
  }

  return (ados_lnksym(gv,sec,xref));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rdi, %r14
cmpl $0x0, 0x54(%rdi)
jne 0x1246e
movq %rsi, %r15
movq 0x10(%rbx), %r13
leaq 0x1d2bb(%rip), %rdi     # 0x2f718
movl $0x2, %edx
movq %r13, %rsi
callq 0x5070
testl %eax, %eax
je 0x12487
movq %r14, %rdi
movq %rbx, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x11dc1
addq $0x2, %r13
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0xb071
testq %rax, %rax
je 0x125dc
movq %rax, (%rsp)
movq %r13, %rdi
callq 0x50e0
leaq 0x3(%rax), %rdi
callq 0x6668
movq %rax, %r12
movl $0x4, %edi
callq 0x66b6
movq %rax, %rbp
leaq 0x10d7c(%rip), %rsi     # 0x2324a
movq %r12, %rdi
movq %r13, %rdx
xorl %eax, %eax
callq 0x5250
movl $0x4, %ecx
movq %r14, %rdi
movq %r12, %rsi
movq %rbp, %rdx
callq 0xbfe9
subq $0x8, %rsp
movl $0x2, %r10d
leaq 0x10d50(%rip), %rsi     # 0x2324f
movl $0x4, %ecx
movq %rax, %rdi
movq %rbp, %rdx
movl $0x2, %r8d
movl $0x1, %r9d
xorl %eax, %eax
pushq %rax
pushq %r10
movl $0x2, %ebp
pushq $0x3
callq 0xc1c8
addq $0x20, %rsp
movq %rax, %r12
movq %r14, %rdi
movq %rax, %rsi
movq %r13, %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
pushq $0x0
movl $0x1, %r13d
pushq %r13
callq 0xb202
addq $0x10, %rsp
movq %r12, %rdi
movq %rax, %rsi
xorl %edx, %edx
movl $0x20, %ecx
movq $-0x1, %r8
callq 0xb2b7
movq 0x10(%rbx), %rdx
subq $0x8, %rsp
movq %r14, %rdi
movq %r12, %rsi
xorl %ecx, %ecx
xorl %r8d, %r8d
movl $0x2, %r9d
xorl %eax, %eax
pushq %rax
pushq $0x4
pushq %rbp
pushq %r13
pushq %rax
callq 0xaba4
addq $0x30, %rsp
testq %rax, %rax
je 0x125ad
movq 0x10(%rbx), %rsi
leaq 0x10caf(%rip), %rdi     # 0x23255
xorl %eax, %eax
callq 0x52b0
movq 0x10(%rbx), %rdx
movq %r14, %rdi
movq %r15, %rsi
callq 0xa82c
movq %rax, %r15
testq %rax, %rax
jne 0x125d6
movq 0x10(%rbx), %rsi
leaq 0x10cd3(%rip), %rdi     # 0x232a2
xorl %eax, %eax
callq 0x52b0
movq (%rsp), %rax
jmp 0x125dc
testq %rax, %rax
je 0x1246e
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq