'not sure how to fix this error - error: unexpected token in '.section' directive .section .text [duplicate]

I bought a book called "learn to program with assembly" as a guide for learning assembly language. it said to download docker and run and create this file called "myexit.s" and copy in a small section of code.

I have copied the code verbatim from the page. it goes like this:

.globl _start

.section .text

_start:

    movq $60, %rax
    movq $3, %rdi
    syscall

so I typed it in correctly, but I am getting this error message :

myexit.s:1:15: error: unexpected token in '.section' directive ....it points a green ^ to the space after the word text.

I have spent some time looking at forums for an answer, but nothing that worked or applied to me. help is appreciated.

by the way I am running docker, Mac Big Sur 11.2.3



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source