elf_section.cpp
This commit is contained in:
34
linux/elf_sections.cpp
Normal file
34
linux/elf_sections.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
VIM: let g:lcppflags="-std=c++11 -O2 -pthread"
|
||||
VIM: let g:wcppflags="/O2 /EHsc /DWIN32"
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <exception>
|
||||
|
||||
char var_bss[];
|
||||
char var_data[] = "string in data";
|
||||
const char var_rodata[] = "string in rodata";
|
||||
|
||||
__attribute__((section(".custom")))
|
||||
char var_custom[] = "string in custom section";
|
||||
|
||||
int main ( void )
|
||||
{try{
|
||||
const char * var_ptr = "string in rodata 2";
|
||||
|
||||
std::cout << var_bss << var_data << var_rodata << var_ptr ;
|
||||
return 0;
|
||||
}
|
||||
catch ( const std::exception& e )
|
||||
{
|
||||
std::cerr << std::endl
|
||||
<< "std::exception(\"" << e.what() << "\")." << std::endl;
|
||||
return 2;
|
||||
}
|
||||
catch ( ... )
|
||||
{
|
||||
std::cerr << std::endl
|
||||
<< "unknown exception." << std::endl;
|
||||
return 1;
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user