// File: /workspace/github_c_makefile_star2_O3/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 0x24c6c(%rip), %rax     # 0x33608
testq %rax, %rax
je 0xe9ab
movq 0x30(%rax), %rax
movq 0x20(%rax), %r15
jmp 0xe9b2
movq $-0x2, %r15
movb $0x0, (%r12)
callq 0xfeed
movl $0x1, %ebx
cmpb $0x28, %al
je 0xe9f4
movzbl %al, %eax
cmpl $0x3a, %eax
je 0xea52
movl $0x1, %edi
callq 0xff51
movq %r15, %rdi
movq %r13, %rsi
callq 0x1004a
callq 0xfeed
movl $0x3, %ebx
cmpb $0x28, %al
jne 0xea4e
movl $0x1, %edi
callq 0xff64
testq %rax, %rax
je 0xeaaa
movq %r12, %rdi
movq %rax, %rsi
callq 0x5080
callq 0xfeed
cmpb $0x29, %al
je 0xea49
movq 0x24bfe(%rip), %r12     # 0x33620
callq 0x103d5
xorl %ebx, %ebx
movl $0x42, %edi
movq %r12, %rsi
movl %eax, %edx
movl $0x29, %ecx
xorl %eax, %eax
callq 0x6f14
movl $0x1, %edi
callq 0xff51
callq 0xfeed
cmpb $0x3a, %al
jne 0xeaaa
movl $0x1, %edi
callq 0xff64
testq %rax, %rax
je 0xea99
movq %rax, %r12
cmpb $0x41, (%rax)
jne 0xea79
cmpb $0x54, 0x1(%r12)
jne 0xea79
cmpb $0x0, 0x2(%r12)
je 0xeae9
movq 0x24ba0(%rip), %r14     # 0x33620
callq 0x103d5
movl $0x41, %edi
movq %r14, %rsi
movl %eax, %edx
movq %r12, %rcx
xorl %eax, %eax
callq 0x6f14
movl $0x7b, %edi
callq 0xf8fc
testl %eax, %eax
cmovel %eax, %ebx
jmp 0xead8
movq 0x24b6f(%rip), %r14     # 0x33620
callq 0x103d5
xorl %ebx, %ebx
movl $0x42, %edi
movq %r14, %rsi
movl %eax, %edx
movl $0x3a, %ecx
xorl %eax, %eax
callq 0x6f14
movl $0x1, %edi
callq 0xff51
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0xfeed
cmpb $0x28, %al
jne 0xeb2f
movq %r15, %rdi
movq %r14, %rsi
callq 0x1004a
leal 0x4(%rbx), %ebp
testl %ebx, %ebx
cmovel %ebx, %ebp
callq 0xfeed
movl %ebp, %ebx
cmpb $0x29, %al
je 0xea99
movq 0x24b09(%rip), %r14     # 0x33620
callq 0x103d5
xorl %ebx, %ebx
movl $0x42, %edi
movq %r14, %rsi
movl %eax, %edx
movl $0x29, %ecx
jmp 0xeb4c
movq 0x24aea(%rip), %r14     # 0x33620
callq 0x103d5
xorl %ebx, %ebx
movl $0x42, %edi
movq %r14, %rsi
movl %eax, %edx
movl $0x28, %ecx
xorl %eax, %eax
callq 0x6f14
movl $0x1, %edi
callq 0xff51
jmp 0xea99