// File: /workspace/github_c_makefile_star2_O2/deplinenoise[P]vlink/t_elf32ppcbe.c
// Function: amiga_lnksym
static struct Symbol *amiga_lnksym(struct GlobalVars *gv,
                                     struct Section *sec,
                                     struct Reloc *xref)
{
  struct Symbol *sym;

  if (!gv->dest_object && !gv->use_ldscript) {
    if (!strcmp(linkerdb,xref->xrefname)) {  /* _LinkerDB */
      sym = addlnksymbol(gv,linkerdb,(lword)fff[gv->dest_format]->baseoff,
                         SYM_RELOC,SYMF_LNKSYM,SYMI_OBJECT,SYMB_GLOBAL,0);
      sym->extra = SYMX_SPECIAL|LINKERDB;
      if (findlnksymbol(gv,sdabase_name) == NULL) {
        /* Reference to _LinkerDB creates _SDA_BASE_ */
        struct Symbol *sdabase = addlnksymbol(gv,sdabase_name,
                                              (lword)fff[gv->dest_format]->baseoff,
                                              SYM_ABS,SYMF_LNKSYM,
                                              SYMI_OBJECT,SYMB_GLOBAL,0);
        sdabase->type = SYM_RELOC;
        sdabase->extra = SDABASE;
      }
      if (findlnksymbol(gv,r13init_name) == NULL) {
        /* Reference to _LinkerDB creates __r13_init */
        struct Symbol *r13init = addlnksymbol(gv,r13init_name,
                                              (lword)fff[gv->dest_format]->baseoff,
                                              SYM_ABS,SYMF_LNKSYM,
                                              SYMI_OBJECT,SYMB_GLOBAL,0);
        r13init->type = SYM_RELOC;
        r13init->extra = SYMX_SPECIAL|R13INIT;
      }
      return (sym);  /* new linker symbol created */
    }

    else if (!strcmp(r13init_name,xref->xrefname)) {  /* __r13_init */
      sym = addlnksymbol(gv,r13init_name,(lword)fff[gv->dest_format]->baseoff,
                         SYM_RELOC,SYMF_LNKSYM,SYMI_OBJECT,SYMB_GLOBAL,0);
      sym->extra = SYMX_SPECIAL|R13INIT;
      return (sym);  /* new linker symbol created */
    }

    else if (!strcmp(sdatasize,xref->xrefname)) {  /* __sdata_size */
      sym = addlnksymbol(gv,sdatasize,0,
                         SYM_ABS,SYMF_LNKSYM,SYMI_OBJECT,SYMB_GLOBAL,0);
      sym->extra = SYMX_SPECIAL|SDATASIZE;
      return (sym);  /* new linker symbol created */
    }

    else if (!strcmp(sbsssize,xref->xrefname)) {  /* __sbss_size */
      sym = addlnksymbol(gv,sbsssize,0,
                         SYM_ABS,SYMF_LNKSYM,SYMI_OBJECT,SYMB_GLOBAL,0);
      sym->extra = SYMX_SPECIAL|SBSSSIZE;
      return (sym);  /* new linker symbol created */
    }

    else if (!strcmp(ddrelocs,xref->xrefname)) {  /* __datadata_relocs */
      sym = addlnksymbol(gv,ddrelocs,0,
                         SYM_RELOC,SYMF_LNKSYM,SYMI_OBJECT,SYMB_GLOBAL,0);
      sym->extra = SYMX_SPECIAL|DDRELOCS;
      return (sym);  /* new linker symbol created */
    }

    else if (!strcmp(textsize,xref->xrefname)) {  /* __text_size */
      sym = addlnksymbol(gv,textsize,0,
                         SYM_ABS,SYMF_LNKSYM,SYMI_OBJECT,SYMB_GLOBAL,0);
      sym->extra = SYMX_SPECIAL|TEXTSIZE;
      return (sym);  /* new linker symbol created */
    }
  }

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

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
cmpl $0x0, 0x54(%rdi)
jne 0x17ef2
cmpl $0x0, 0x244(%rbx)
je 0x17f0b
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x14617
movq 0x10(%r14), %r12
leaq 0x1802a(%rip), %rdi     # 0x2ff40
movq %r12, %rsi
callq 0x5160
testl %eax, %eax
je 0x17fce
leaq 0x8718(%rip), %rdi      # 0x20645
movq %r12, %rsi
callq 0x5160
testl %eax, %eax
je 0x180b3
leaq 0x18006(%rip), %rdi     # 0x2ff4a
movq %r12, %rsi
callq 0x5160
testl %eax, %eax
je 0x180fd
leaq 0x17ffc(%rip), %rdi     # 0x2ff57
movq %r12, %rsi
callq 0x5160
testl %eax, %eax
je 0x1812f
leaq 0x17ffe(%rip), %rdi     # 0x2ff70
movq %r12, %rsi
callq 0x5160
testl %eax, %eax
je 0x18161
leaq 0x17ff9(%rip), %rdi     # 0x2ff82
movq %r12, %rsi
callq 0x5160
testl %eax, %eax
jne 0x17ef2
andl $0x0, 0x8(%rsp)
movl $0x2, (%rsp)
leaq 0x17fd6(%rip), %rsi     # 0x2ff82
pushq $0x1
popq %rcx
movq %rbx, %rdi
xorl %edx, %edx
movl %ecx, %r8d
movl %ecx, %r9d
callq 0xa880
movq %rax, %r14
movl $0x80000005, 0x48(%rax) # imm = 0x80000005
jmp 0x18192
movzbl 0x50(%rbx), %eax
leaq 0x171b7(%rip), %r15     # 0x2f190
movq (%r15,%rax,8), %rax
movslq 0x9c(%rax), %rdx
andl $0x0, 0x8(%rsp)
movl $0x2, (%rsp)
leaq 0x17f49(%rip), %rsi     # 0x2ff40
pushq $0x2
popq %rcx
pushq $0x1
popq %r8
movq %rbx, %rdi
movl %r8d, %r9d
callq 0xa880
movq %rax, %r14
movl $0x80000000, 0x48(%rax) # imm = 0x80000000
leaq 0x85cb(%rip), %rsi      # 0x205e5
movq %rbx, %rdi
callq 0xa922
testq %rax, %rax
jne 0x18062
movzbl 0x50(%rbx), %eax
movq (%r15,%rax,8), %rax
movslq 0x9c(%rax), %rdx
andl $0x0, 0x8(%rsp)
movl $0x2, (%rsp)
leaq 0x859c(%rip), %rsi      # 0x205e5
pushq $0x1
popq %rcx
movq %rbx, %rdi
movl %ecx, %r8d
movl %ecx, %r9d
callq 0xa880
movb $0x2, 0x40(%rax)
andl $0x0, 0x48(%rax)
leaq 0x85dc(%rip), %rsi      # 0x20645
movq %rbx, %rdi
callq 0xa922
testq %rax, %rax
jne 0x18192
movzbl 0x50(%rbx), %eax
movq (%r15,%rax,8), %rax
movslq 0x9c(%rax), %rdx
andl $0x0, 0x8(%rsp)
movl $0x2, (%rsp)
leaq 0x85a9(%rip), %rsi      # 0x20645
pushq $0x1
popq %rcx
movq %rbx, %rdi
movl %ecx, %r8d
movl %ecx, %r9d
callq 0xa880
movb $0x2, 0x40(%rax)
jmp 0x180f1
movzbl 0x50(%rbx), %eax
leaq 0x170d2(%rip), %rcx     # 0x2f190
movq (%rcx,%rax,8), %rax
movslq 0x9c(%rax), %rdx
andl $0x0, 0x8(%rsp)
movl $0x2, (%rsp)
leaq 0x8569(%rip), %rsi      # 0x20645
pushq $0x2
popq %rcx
pushq $0x1
popq %r8
movq %rbx, %rdi
movl %r8d, %r9d
callq 0xa880
movq %rax, %r14
movl $0x80000001, 0x48(%rax) # imm = 0x80000001
jmp 0x18192
andl $0x0, 0x8(%rsp)
movl $0x2, (%rsp)
leaq 0x17e3a(%rip), %rsi     # 0x2ff4a
pushq $0x1
popq %rcx
movq %rbx, %rdi
xorl %edx, %edx
movl %ecx, %r8d
movl %ecx, %r9d
callq 0xa880
movq %rax, %r14
movl $0x80000002, 0x48(%rax) # imm = 0x80000002
jmp 0x18192
andl $0x0, 0x8(%rsp)
movl $0x2, (%rsp)
leaq 0x17e15(%rip), %rsi     # 0x2ff57
pushq $0x1
popq %rcx
movq %rbx, %rdi
xorl %edx, %edx
movl %ecx, %r8d
movl %ecx, %r9d
callq 0xa880
movq %rax, %r14
movl $0x80000003, 0x48(%rax) # imm = 0x80000003
jmp 0x18192
andl $0x0, 0x8(%rsp)
movl $0x2, (%rsp)
leaq 0x17dfc(%rip), %rsi     # 0x2ff70
pushq $0x2
popq %rcx
pushq $0x1
popq %r8
movq %rbx, %rdi
xorl %edx, %edx
movl %r8d, %r9d
callq 0xa880
movq %rax, %r14
movl $0x80000004, 0x48(%rax) # imm = 0x80000004
movq %r14, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq