// File: /workspace/github_c_makefile_star2_O1/deplinenoise[P]vlink/ldscript.c
// Function: startofsecdef
static int startofsecdef(lword *s_addr,char *s_type,lword *s_lma)
/* Parse syntax of section definition until '{' and return VMA address,
   LMA address and type, when given.
   Returns bitfield. 0 when syntax is incorrect, 1 for correct,
   3 for s_addr set, 5 for s_lma set and 7 for both.
   Syntax: [addr-expr] [(type)] : [AT(lma)] { */
{
  int ret = 1;
  lword caddr = -2; /* this prevents expression evaluation during pre-parse */
  char *buf,c;

  if (current_ls)
    caddr = current_ls->relocmem->current;

  *s_type = 0;

  c = getchr();
  if (c != ':') {
    if (c != '(') {
      back(1);
      parse_expr(caddr,s_addr);
#if 0 /* @@@ not needed? address must be within memory region */
      if (current_ls) {
        if (current_ls->relocmem != defmem) {
          /* warning: address overrides specified VMA memory region */
          error(76,scriptname,getlineno(),'V');
          current_ls->relocmem = defmem;
        }
      }
#endif
      ret |= 2;
      c = getchr();
    }
    if (c == '(') {
      if (buf = getword()) {
        strcpy(s_type,buf);
        if (getchr() != ')') {
          error(66,scriptname,getlineno(),')');  /* ')' expected */
          back(1);
          ret = 0;
        }
        c = getchr();
      }
    }
  }

  if (c != ':') {
    error(66,scriptname,getlineno(),':');  /* ':' expected */
    back(1);
    return 0;
  }

  if (buf = getword()) {
    if (!strcmp(buf,"AT")) {
      if (getchr()=='(') {
        parse_expr(caddr,s_lma);
#if 0 /* @@@ not needed? address must be within memory region */
        if (current_ls) {
          if (current_ls->destmem != defmem) {
            if (current_ls->destmem != current_ls->relocmem) {
              /* warning: address overrides specified LMA memory region */
              error(76,scriptname,getlineno(),'L');
            }
            current_ls->destmem = atdefmem;
          }
        }
#endif
        if (ret)
          ret |= 4;
        if (getchr() != ')') {
          error(66,scriptname,getlineno(),')');  /* ')' expected */
          back(1);
          ret = 0;
        }
      }
      else {
        error(66,scriptname,getlineno(),'(');  /* '(' expected */
        back(1);
        ret = 0;
      }
    }
    else
      error(65,scriptname,getlineno(),buf);  /* unknown keyword ignored */
  }

  if (!startofblock('{'))
    ret = 0;

  return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %r13
movq 0x24b3f(%rip), %rax     # 0x33608
testq %rax, %rax
je 0xead8
movq 0x30(%rax), %rax
movq 0x20(%rax), %r15
jmp 0xeadf
movq $-0x2, %r15
movb $0x0, (%r12)
callq 0x1006f
movl %eax, %ebp
movl $0x1, %ebx
cmpb $0x28, %al
je 0xeb1e
movzbl %bpl, %eax
cmpl $0x3a, %eax
je 0xeb7c
movl $0x1, %edi
callq 0x100d3
movq %r15, %rdi
movq %r13, %rsi
callq 0x101d8
movl $0x3, %ebx
callq 0x1006f
movl %eax, %ebp
cmpb $0x28, %bpl
jne 0xeb7c
movl $0x1, %edi
callq 0x100e6
testq %rax, %rax
je 0xeb7c
movq %r12, %rdi
movq %rax, %rsi
callq 0x5080
callq 0x1006f
cmpb $0x29, %al
je 0xeb75
movq 0x24ad2(%rip), %r12     # 0x33620
callq 0x10563
xorl %ebx, %ebx
movl $0x42, %edi
movq %r12, %rsi
movl %eax, %edx
movl $0x29, %ecx
xorl %eax, %eax
callq 0x6f84
movl $0x1, %edi
callq 0x100d3
callq 0x1006f
movl %eax, %ebp
cmpb $0x3a, %bpl
jne 0xebd0
movl $0x1, %edi
callq 0x100e6
testq %rax, %rax
je 0xec77
movq %rax, %r12
leaq 0x13b10(%rip), %rsi     # 0x226af
movq %rax, %rdi
callq 0x5160
testl %eax, %eax
je 0xec03
movq 0x24a6e(%rip), %r14     # 0x33620
callq 0x10563
movl $0x41, %edi
movq %r14, %rsi
movl %eax, %edx
movq %r12, %rcx
xorl %eax, %eax
callq 0x6f84
jmp 0xec77
movq 0x24a49(%rip), %r14     # 0x33620
callq 0x10563
xorl %ebx, %ebx
movl $0x42, %edi
movq %r14, %rsi
movl %eax, %edx
movl $0x3a, %ecx
xorl %eax, %eax
callq 0x6f84
movl $0x1, %edi
callq 0x100d3
jmp 0xec86
callq 0x1006f
cmpb $0x28, %al
jne 0xec49
movq %r15, %rdi
movq %r14, %rsi
callq 0x101d8
leal 0x4(%rbx), %ebp
testl %ebx, %ebx
cmovel %ebx, %ebp
callq 0x1006f
movl %ebp, %ebx
cmpb $0x29, %al
je 0xec77
movq 0x249ef(%rip), %r14     # 0x33620
callq 0x10563
xorl %ebx, %ebx
movl $0x42, %edi
movq %r14, %rsi
movl %eax, %edx
movl $0x29, %ecx
jmp 0xec66
movq 0x249d0(%rip), %r14     # 0x33620
callq 0x10563
xorl %ebx, %ebx
movl $0x42, %edi
movq %r14, %rsi
movl %eax, %edx
movl $0x28, %ecx
xorl %eax, %eax
callq 0x6f84
movl $0x1, %edi
callq 0x100d3
movl $0x7b, %edi
callq 0xfa78
testl %eax, %eax
cmovel %eax, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq