1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 21da177e4SLinus Torvalds /* 31da177e4SLinus Torvalds * Copyright (C) 2002-2003 David McCullough <davidm@snapgear.com> 41da177e4SLinus Torvalds * Copyright (C) 1998 Kenneth Albanowski <kjahds@kjahds.com> 51da177e4SLinus Torvalds * The Silver Hammer Group, Ltd. 61da177e4SLinus Torvalds * 71da177e4SLinus Torvalds * This file provides the definitions and structures needed to 81da177e4SLinus Torvalds * support uClinux flat-format executables. 91da177e4SLinus Torvalds */ 101da177e4SLinus Torvalds #ifndef _LINUX_FLAT_H 111da177e4SLinus Torvalds #define _LINUX_FLAT_H 121da177e4SLinus Torvalds 1306d2bfedSChristoph Hellwig #define FLAT_VERSION 0x00000004L 1406d2bfedSChristoph Hellwig 1506d2bfedSChristoph Hellwig /* 1606d2bfedSChristoph Hellwig * To make everything easier to port and manage cross platform 1706d2bfedSChristoph Hellwig * development, all fields are in network byte order. 1806d2bfedSChristoph Hellwig */ 1906d2bfedSChristoph Hellwig 2006d2bfedSChristoph Hellwig struct flat_hdr { 2106d2bfedSChristoph Hellwig char magic[4]; 2234b4664aSChristoph Hellwig __be32 rev; /* version (as above) */ 2334b4664aSChristoph Hellwig __be32 entry; /* Offset of first executable instruction 2406d2bfedSChristoph Hellwig with text segment from beginning of file */ 2534b4664aSChristoph Hellwig __be32 data_start; /* Offset of data segment from beginning of 2606d2bfedSChristoph Hellwig file */ 2734b4664aSChristoph Hellwig __be32 data_end; /* Offset of end of data segment from beginning 2834b4664aSChristoph Hellwig of file */ 2934b4664aSChristoph Hellwig __be32 bss_end; /* Offset of end of bss segment from beginning 3006d2bfedSChristoph Hellwig of file */ 3106d2bfedSChristoph Hellwig 3206d2bfedSChristoph Hellwig /* (It is assumed that data_end through bss_end forms the bss segment.) */ 3306d2bfedSChristoph Hellwig 3434b4664aSChristoph Hellwig __be32 stack_size; /* Size of stack, in bytes */ 3534b4664aSChristoph Hellwig __be32 reloc_start; /* Offset of relocation records from beginning of 3634b4664aSChristoph Hellwig file */ 3734b4664aSChristoph Hellwig __be32 reloc_count; /* Number of relocation records */ 3834b4664aSChristoph Hellwig __be32 flags; 3934b4664aSChristoph Hellwig __be32 build_date; /* When the program/library was built */ 4034b4664aSChristoph Hellwig __u32 filler[5]; /* Reservered, set to zero */ 4106d2bfedSChristoph Hellwig }; 4206d2bfedSChristoph Hellwig 4306d2bfedSChristoph Hellwig #define FLAT_FLAG_RAM 0x0001 /* load program entirely into RAM */ 4406d2bfedSChristoph Hellwig #define FLAT_FLAG_GOTPIC 0x0002 /* program is PIC with GOT */ 4506d2bfedSChristoph Hellwig #define FLAT_FLAG_GZIP 0x0004 /* all but the header is compressed */ 4606d2bfedSChristoph Hellwig #define FLAT_FLAG_GZDATA 0x0008 /* only data/relocs are compressed (for XIP) */ 4706d2bfedSChristoph Hellwig #define FLAT_FLAG_KTRACE 0x0010 /* output useful kernel trace for debugging */ 481da177e4SLinus Torvalds 491da177e4SLinus Torvalds /* 501da177e4SLinus Torvalds * While it would be nice to keep this header clean, users of older 511da177e4SLinus Torvalds * tools still need this support in the kernel. So this section is 521da177e4SLinus Torvalds * purely for compatibility with old tool chains. 531da177e4SLinus Torvalds * 541da177e4SLinus Torvalds * DO NOT make changes or enhancements to the old format please, just work 551da177e4SLinus Torvalds * with the format above, except to fix bugs with old format support. 561da177e4SLinus Torvalds */ 571da177e4SLinus Torvalds 581da177e4SLinus Torvalds #define OLD_FLAT_VERSION 0x00000002L 591da177e4SLinus Torvalds #define OLD_FLAT_RELOC_TYPE_TEXT 0 601da177e4SLinus Torvalds #define OLD_FLAT_RELOC_TYPE_DATA 1 611da177e4SLinus Torvalds #define OLD_FLAT_RELOC_TYPE_BSS 2 621da177e4SLinus Torvalds 631da177e4SLinus Torvalds typedef union { 6434b4664aSChristoph Hellwig u32 value; 651da177e4SLinus Torvalds struct { 663f8b76a6SChristoph Hellwig #if defined(__LITTLE_ENDIAN_BITFIELD) || \ 673f8b76a6SChristoph Hellwig (defined(mc68000) && !defined(CONFIG_COLDFIRE)) 6834b4664aSChristoph Hellwig s32 offset : 30; 6934b4664aSChristoph Hellwig u32 type : 2; 701da177e4SLinus Torvalds # elif defined(__BIG_ENDIAN_BITFIELD) 7134b4664aSChristoph Hellwig u32 type : 2; 7234b4664aSChristoph Hellwig s32 offset : 30; 731da177e4SLinus Torvalds # else 741da177e4SLinus Torvalds # error "Unknown bitfield order for flat files." 751da177e4SLinus Torvalds # endif 761da177e4SLinus Torvalds } reloc; 771da177e4SLinus Torvalds } flat_v2_reloc_t; 781da177e4SLinus Torvalds 791da177e4SLinus Torvalds #endif /* _LINUX_FLAT_H */ 80