// File: /workspace/github_c_makefile_star2_O0/deplinenoise[P]vlink/t_elf32ppcbe.c
// Function: ppc32be_dynentry
static struct Symbol *ppc32be_dynentry(struct GlobalVars *gv,DynArg a,int etype)
/* Create an entry into .got/.plt/.bss for the referenced symbol. */
{
  struct Symbol *entry_sym = NULL;
  struct Section *sec;
  const char *bssname;

  switch (etype) {

    case GOT_ENTRY:
    case GOT_LOCAL:
      /* .got has 4 reserved words at the beginning,
         is writable and executable (contains a blrl in first word),
         a new entry occupies 1 word. */
      sec = elf32_dyntable(gv,16,16,ST_DATA,SF_ALLOC,
                           SP_READ|SP_WRITE|SP_EXEC,GOT_ENTRY);
      entry_sym = elf32_pltgotentry(gv,sec,a,SYMI_OBJECT,4,4,etype);
      break;

    case PLT_ENTRY:
      /* .plt has 18 reserved words at the beginning,
         is writable and executable, but uninitialized for PPC,
         a new entry occupies 2 words and 1 additional word at the end */
      sec = elf32_dyntable(gv,72,72,ST_UDATA,SF_ALLOC|SF_UNINITIALIZED,
                           SP_READ|SP_WRITE|SP_EXEC,PLT_ENTRY);
      entry_sym = elf32_pltgotentry(gv,sec,a,SYMI_FUNC,8,12,PLT_ENTRY);
      break;

    case BSS_ENTRY:
      /* small objects are copied to .sbss, larger ones to .bss */
      bssname = (a.sym->size <= SBSS_MAXSIZE) ? sbss_name : bss_name;
      entry_sym = elf32_bssentry(gv,bssname,a.sym);
      break;

    case STR_ENTRY:
      /* enter StrTabList .dynstr */
      elf32_adddynstr(a.name);
      break;

    case SYM_ENTRY:
      /* enter SymTabList .dynsym and name to .dynstr */
      elf32_adddynsym(a.sym);
      break;

    case SO_NEEDED:
      /* denote shared object's name as 'needed' */
      elf32_dynamicentry(gv,DT_NEEDED,elf32_adddynstr(a.name),NULL);
      break;

    default:
      ierror("ppc32be_dynentry(): illegal entrytype: %d",etype);
      break;
  }

  return entry_sym;
}

// Assembly:
subq $0x48, %rsp
movq %rsi, 0x40(%rsp)
movq %rdi, 0x38(%rsp)
movl %edx, 0x34(%rsp)
movq $0x0, 0x28(%rsp)
movl 0x34(%rsp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, 0x10(%rsp)
subl $0x7, %eax
ja 0x27c6b
movq 0x10(%rsp), %rax
leaq 0xedeb(%rip), %rcx      # 0x36908
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x38(%rsp), %rdi
movl $0x10, %edx
movl $0x2, %ecx
movl $0x1, %r8d
movl $0x7, %r9d
movq %rdx, %rsi
movl $0x1, (%rsp)
callq 0x22740
movq %rax, 0x20(%rsp)
movq 0x38(%rsp), %rdi
movq 0x20(%rsp), %rsi
movl 0x34(%rsp), %eax
movq 0x40(%rsp), %rdx
movl $0x1, %ecx
movl $0x4, %r9d
movq %r9, %r8
movl %eax, (%rsp)
callq 0x22c30
movq %rax, 0x28(%rsp)
jmp 0x27c7d
movq 0x38(%rsp), %rdi
movl $0x48, %edx
movl $0x3, %r8d
movl $0x7, %r9d
movq %rdx, %rsi
movl %r8d, %ecx
movl $0x2, (%rsp)
callq 0x22740
movq %rax, 0x20(%rsp)
movq 0x38(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq 0x40(%rsp), %rdx
movl $0x2, %ecx
movl $0x8, %r8d
movl $0xc, %r9d
movl $0x2, (%rsp)
callq 0x22c30
movq %rax, 0x28(%rsp)
jmp 0x27c7d
movq 0x40(%rsp), %rax
movl 0x44(%rax), %edx
leaq 0xd9b2(%rip), %rax      # 0x355ac
leaq 0xd9b7(%rip), %rcx      # 0x355b8
cmpl $0x4, %edx
cmovbeq %rcx, %rax
movq %rax, 0x18(%rsp)
movq 0x38(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq 0x40(%rsp), %rdx
callq 0x23100
movq %rax, 0x28(%rsp)
jmp 0x27c7d
movq 0x40(%rsp), %rdi
callq 0x23770
jmp 0x27c7d
movq 0x40(%rsp), %rdi
callq 0x22610
jmp 0x27c7d
movq 0x38(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x40(%rsp), %rdi
callq 0x23770
movq 0x8(%rsp), %rdi
movl %eax, %edx
movl $0x1, %esi
xorl %eax, %eax
movl %eax, %ecx
callq 0x23210
jmp 0x27c7d
movl 0x34(%rsp), %esi
leaq 0xee3a(%rip), %rdi      # 0x36ab0
movb $0x0, %al
callq 0x8ae0
movq 0x28(%rsp), %rax
addq $0x48, %rsp
retq
nopw (%rax,%rax)