What exactly will happen to the data segment and text segment if I use the below two lines in my c source code file?
#pragma CODE_SECTION(func1, \"Sec1\")
#p
#pragma means "here follows something implementation-defined unique to this compiler". So what will happen depends on the compiler you are using. If the compiler doesn't support this specific pragma, the whole thing will be ignored.
In this case it is fairly obvious, however.
#pragma CODE_SECTION(func1, "Sec1") means: "func1 should be in program memory, in the memory area called Sec1". Sec1 will be a read-only memory location where the actual code of func1 will be allocated.
#pragma DATA_SECTION(globalvar1, "Sec2") means: "globalvar1 should be in data memory, in the memory area called Sec2". Sec2 will be a read/write location where the variable globalvar1 will be allocated.