GDB Usage

Check memory layout To check the memory layout of a binary in GDB, you can use different commands depending on whether the program is currently running or if you are just inspecting the static binary file. 1. If the Program is Running The best command to see the virtual memory mappings (including the heap, stack, and loaded libraries) is: info proc mappings What it shows: Start/End Addr: The virtual address range. Size: The size of the mapped region. Offset: Offset into the file (if file-backed). Objfile: The specific…

Check whether an executable is pure C or CPP

Distinguishing between a pure C and a C++ executable can be achieved by examining the symbols and library dependencies of the binary file. C++ compilers employ a technique called "name mangling" to support function overloading and namespaces, which is absent in C. Furthermore, C++ programs have a distinct set of standard library dependencies. Inspecting Symbol Tables for Name Mangling A primary indicator of C++ code is the presence of "mangled" names in the executable's symbol table. C++ compilers alter function and variable names to encode information about their…

Setup Docker on Ubuntu 25.10

To set up Docker on Ubuntu 25.10 (Questing Quokka), follow these steps. These instructions use the official Docker repository to ensure you get the latest version. Step 1: Uninstall Old Versions Conflicting packages (like docker.io or podman-docker) might be installed by default. Remove them to prevent conflicts: sudo apt-get remove docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc Step 2: Set Up the Docker Repository 1、Update your package index and install necessary dependencies: sudo apt-get update sudo apt-get install ca-certificates curl 2、Add Docker’s official GPG key: sudo install -m 0755 -d /etc/apt/keyrings sudo curl…

WordPress site Migration from CentOS7 to Ubuntu24

Phase 1: Preparation on CentOS 7 (Source Server) First, you need to back up your data. Log in to your CentOS server via SSH. 1、Backup the DatabaseRun this command to export your database to a SQL file.(Replace db_name, db_user with your actual database details) mysqldump -u db_user -p db_name > wordpress_backup.sql 2、Backup WordPress FilesCompress your website files into a single archive to make the transfer easier.(Assuming your site is at /var/www/html or /usr/share/nginx/html) tar -czf wordpress_files.tar.gz /var/www/html Phase 2: Setup Ubuntu 24.04 (Destination Server) Log in to your new Ubuntu 24.04 server. You need…

How to reset ZeroTier moon node

ZeroTier Installation ZeroTier provides a script that detects your OS, adds the correct GPG keys and repositories, and installs the package for you. # Install curl (if missing): sudo apt update && sudo apt install curl -y # Run the install script: curl -s https://install.zerotier.com | sudo bash # Check Status: sudo zerotier-cli status # Enable on Boot: sudo systemctl enable zerotier-one Deorbit obsolete Moon Node To check if your client is connected to a Moon node and to remove it ("de-orbit"), follow these steps. sudo zerotier-cli listpeers…

Ubuntu XRDP

XRDP is a cross-platform remote desktop connection tool that can be used on Windows and Linux . Using XRDP on Ubuntu allows you to remotely connect to a Linux from a Windows computer for file transfer, remote control, and other operations. Install XRDP First, you need to install XRDP on Ubuntu. Open the terminal and enter the following command to install it: sudo apt updatesudo apt install xrdp After the installation is complete, you can check whether XRDP was successfully installed by entering the following command: xrdp --version…

An introduction to GCC and GCC’s plugins

1. Brief introduction to GNU’s GCC The GNU toolchain is a collection of tools and libraries produced in the context of the GNU project. In 1983, Richard Stallman announced the GNU project. Its goal was to give the community freedom and control in their use of computing devices by developing (collaboratively) free software and letting users modify, copy, and distribute it freely. The GNU toolchain was part of that software and today includes some of the most widespread tools used to develop and compile application such as: GNU make:…

How to run a program with commandline arguments using GDB within a Bash script?

Run gdb with --args parameter: gdb --args executablename arg1 arg2 arg3 If you are doing this often (e.g. when running GDB from a script), you might want to consider the following arguments to automate things further. First, you can place your GDB commands (such as 'run') in a text file and provide the filename to the -x argument. Second, you can have GDB exit after running your commands by providing the --batch argument. A full example: gdb -x commands.txt --batch --args executablename arg1 arg2 arg3

Lima Ubuntu VM setup on Mac

Homebrew Installation /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)" Uninstallation /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/HomebrewUninstall.sh)" Lima  launches Linux virtual machines with automatic file sharing and port forwarding (similar to WSL2). # Install brew install lima # Create VM limactl create --cpus=8 --memory=8 --name=default template://ubuntu limactl list # Start && Enter limactl start default limactl shell default # Stop limactl stop default # Delete limactl delete default # Protect && Unprotect limactl protect default limactl unprotect default # Copy # Host -> VM limactl cp ~/Downloads/test.png default:/tmp # VM -> Host…

How to run SPEC CPU2017 and disable checksum

1. Environment Preparation ​Install Dependencies: For Ubuntu/Debian (ARM cross-compilation example): sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu gfortran-aarch64-linux-gnu Ensure ulimit is set to unlimited: ulimit -s unlimited 2. Install SPEC CPU2017 ​Mount the ISO File: mount -o loop cpu2017-1.1.5.iso /mnt # Mount ISO to /mnt mkdir /home/speccpu cp /mnt/* -r /home/speccpu # Copy files to installation directory chmod -R 755 /home/speccpu # Set permissions Run Installation Script: cd /home/speccpu ./install.sh # Follow prompts and confirm with "yes" 3. Configure the Test Environment ​Modify the Configuration File: Copy the default config (e.g., Example-gcc-linux-aarch64.cfg) and…