// File: /workspace/github_c_makefile_star2_O0/deplinenoise[P]vlink/t_elf32.c
// Function: elf32_pltgotentry
struct Symbol *elf32_pltgotentry(struct GlobalVars *gv,struct Section *sec,
                                 DynArg a,uint8_t entrysymtype,
                                 unsigned long offsadd,unsigned long sizeadd,
                                 int etype)
/* Make a table entry for indirectly accessing a location from an external
   symbol defintion (GOT_ENTRY/PLT_ENTRY) or a local relocation (GOT_LOCAL).
   The entry has a size of offsadd bytes, while the table section sec will
   become sizeadd bytes larger per entry. */
{
  const char *fn = "elf32_pltgotentry():";
  char entryname[MAXLEN];
  struct Symbol *tabsym;
  struct Section *refsec;
  unsigned long refoffs;

  /* determine reference section and offset of ext. symbol or local reloc */
  if (etype == GOT_LOCAL) {
    refsec = a.rel->relocsect.ptr;
    refoffs = a.rel->offset;
  }
  else {
    refsec = a.sym->relsect;
    refoffs = (unsigned long)a.sym->value;
  }

  /* generate internal symbol name for this reference */
  snprintf(entryname,MAXLEN," %s@%lx@%lx",
           sec->name,(unsigned long)refsec,refoffs);

  /* create internal symbol, or return old one, when already present */
  tabsym = addsymbol(gv,sec,allocstring(entryname),NULL,(lword)sec->offset,
                     SYM_RELOC,0,entrysymtype,SYMB_LOCAL,offsadd,FALSE);

  /* tabsym is NULL when it was just created, otherwise we already got it */
  if (tabsym == NULL) {
    static uint8_t dyn_reloc_types[] = { R_NONE,R_GLOBDAT,R_JMPSLOT,R_COPY };
    struct Reloc *r;
    uint8_t rtype;

    tabsym = findlocsymbol(gv,sec->obj,entryname);
    if (tabsym == NULL) {
      ierror("%s %s-symbol refering to %s+%lx disappeared",
             fn,sec->name,refsec->name,refoffs);
    }

    /* create a relocation for the new entry */
    if (etype == GOT_LOCAL) {
      /* local symbol: GOT relocation can be resolved now */
      r = newreloc(gv,sec,NULL,refsec,0,sec->offset,R_ABS,(lword)refoffs);
    }
    else {
      /* we need a dynamic linker relocation at the entry's offset */
      r = newreloc(gv,sec,a.sym->name,NULL,0,sec->offset,
                   dyn_reloc_types[etype],0);
      r->relocsect.symbol = a.sym;  /* resolve with external symbol */
      /* Possible enhancement: Find out whether referenced symbol resides
         in an uninitialized section, without a relocation, then we don't
         need an R_COPY relocation either! */
    }
    addreloc(sec,r,0,32,-1);  /* size,mask only important for R_ABS */
    elf32_dynreloc(gv->dynobj,r,gv->reloctab_format==RTAB_ADDEND);

    /* increase offset and size counters of table-section */
    sec->offset += offsadd;
    sec->size += sizeadd;
  }

  return tabsym;
}

// Assembly:
subq $0x198, %rsp            # imm = 0x198
movb %cl, %al
movl 0x1a0(%rsp), %ecx
movq %rdx, 0x190(%rsp)
movq %rdi, 0x188(%rsp)
movq %rsi, 0x180(%rsp)
movb %al, 0x17f(%rsp)
movq %r8, 0x170(%rsp)
movq %r9, 0x168(%rsp)
leaq 0x13773(%rip), %rax     # 0x363e9
movq %rax, 0x160(%rsp)
cmpl $0x4, 0x1a0(%rsp)
jne 0x22cac
movq 0x190(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x50(%rsp)
movq 0x190(%rsp), %rax
movq 0x20(%rax), %rax
movq %rax, 0x48(%rsp)
jmp 0x22cce
movq 0x190(%rsp), %rax
movq 0x38(%rax), %rax
movq %rax, 0x50(%rsp)
movq 0x190(%rsp), %rax
movq 0x30(%rax), %rax
movq %rax, 0x48(%rsp)
leaq 0x60(%rsp), %rdi
movq 0x180(%rsp), %rax
movq 0x20(%rax), %rcx
movq 0x50(%rsp), %r8
movq 0x48(%rsp), %r9
movl $0x100, %esi            # imm = 0x100
leaq 0x13709(%rip), %rdx     # 0x363fe
movb $0x0, %al
callq 0x50e0
movq 0x188(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x180(%rsp), %rax
movq %rax, 0x30(%rsp)
leaq 0x60(%rsp), %rdi
callq 0x72d0
movq 0x28(%rsp), %rdi
movq 0x30(%rsp), %rsi
movq %rax, %rdx
movq 0x180(%rsp), %rax
movq 0x38(%rax), %r8
movb 0x17f(%rsp), %r10b
movq 0x170(%rsp), %rax
xorl %ecx, %ecx
movl $0x2, %r9d
xorl %r11d, %r11d
movl $0x0, (%rsp)
movzbl %r10b, %r10d
movl %r10d, 0x8(%rsp)
movl $0x1, 0x10(%rsp)
movl %eax, 0x18(%rsp)
movl $0x0, 0x20(%rsp)
callq 0xfd00
movq %rax, 0x58(%rsp)
cmpq $0x0, 0x58(%rsp)
jne 0x22f20
movq 0x188(%rsp), %rdi
movq 0x180(%rsp), %rax
movq 0x10(%rax), %rsi
leaq 0x60(%rsp), %rdx
callq 0x10010
movq %rax, 0x58(%rsp)
cmpq $0x0, 0x58(%rsp)
jne 0x22de9
movq 0x160(%rsp), %rsi
movq 0x180(%rsp), %rax
movq 0x20(%rax), %rdx
movq 0x50(%rsp), %rax
movq 0x20(%rax), %rcx
movq 0x48(%rsp), %r8
leaq 0x13628(%rip), %rdi     # 0x3640a
movb $0x0, %al
callq 0x8ae0
cmpl $0x4, 0x1a0(%rsp)
jne 0x22e36
movq 0x188(%rsp), %rdi
movq 0x180(%rsp), %rsi
movq 0x50(%rsp), %rcx
movq 0x180(%rsp), %rax
movq 0x38(%rax), %r9
movq 0x48(%rsp), %rax
xorl %edx, %edx
xorl %r8d, %r8d
movl $0x1, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x10850
movq %rax, 0x40(%rsp)
jmp 0x22ea0
movq 0x188(%rsp), %rdi
movq 0x180(%rsp), %rsi
movq 0x190(%rsp), %rax
movq 0x20(%rax), %rdx
movq 0x180(%rsp), %rax
movq 0x38(%rax), %r9
movslq 0x1a0(%rsp), %r10
xorl %eax, %eax
movl %eax, %ecx
xorl %r8d, %r8d
leaq 0x1d504(%rip), %rax     # 0x40378
movzbl (%rax,%r10), %eax
movl %eax, (%rsp)
movq $0x0, 0x8(%rsp)
callq 0x10850
movq %rax, 0x40(%rsp)
movq 0x190(%rsp), %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x18(%rax)
movq 0x180(%rsp), %rdi
movq 0x40(%rsp), %rsi
xorl %edx, %edx
movl $0x20, %ecx
movq $-0x1, %r8
callq 0x109b0
movq 0x188(%rsp), %rax
movq 0x1e0(%rax), %rdi
movq 0x40(%rsp), %rsi
movq 0x188(%rsp), %rax
movzbl 0x6e(%rax), %eax
cmpl $0x2, %eax
sete %al
andb $0x1, %al
movzbl %al, %edx
callq 0x22f30
movq 0x170(%rsp), %rcx
movq 0x180(%rsp), %rax
addq 0x38(%rax), %rcx
movq %rcx, 0x38(%rax)
movq 0x168(%rsp), %rcx
movq 0x180(%rsp), %rax
addq 0x48(%rax), %rcx
movq %rcx, 0x48(%rax)
movq 0x58(%rsp), %rax
addq $0x198, %rsp            # imm = 0x198
retq
nopl (%rax)