• linux-4.1的O0编译


    1. 去除最顶层Makefile的-Os/-O2, 替换为-O0
    2. 替换include/linux/complier.h中:避免缺乏了编译预判后,编译时的报错被触发。
      1. #if 1 //zjr
        #define __compiletime_assert(condition, msg, prefix, suffix) BUG_ON(!condition)
        #else
        #define __compiletime_assert(condition, msg, prefix, suffix)            
                do {                                                            
                        bool __cond = !(condition);                             
                        extern void prefix ## suffix(void) __compiletime_error(msg); 
                        if (__cond)                                             
                                prefix ## suffix();                             
                        __compiletime_error_fallback(__cond);                   
                } while (0)
        #endif
    3. jump label报错 asm goto,直接在vim ./arch/arm64/include/asm/jump_label.h中 注释掉代码
      1. static __always_inline bool arch_static_branch(struct static_key *key)
        {
        #if 0 //zjr
                asm goto("1: nop
        	"
                         ".pushsection __jump_table,  "aw"
        	"
                         ".align 3
        	"
                         ".quad 1b, %l[l_yes], %c0
        	"
                         ".popsection
        	"
                         :  :  "i"(key) :  : l_yes);
        
                return false;
        l_yes:
        #endif
                return true;
        }

        PS: JUMP TABLE是对unlikely/likely的优化,彻底去掉了if语句,用jmp指令代替,详见:https://blog.csdn.net/dog250/article/details/6123517 

    4. modpost mismatch count 报错,修改scripts/mod/modpost.c
      1.         if (dump_write)
                        write_dump(dump_write);
        #if 0 //zjr
                if (sec_mismatch_count && !sec_mismatch_verbose)
                        warn("modpost: Found %d section mismatch(es).
        "
                             "To see full details build your kernel with:
        "
                             "'make CONFIG_DEBUG_SECTION_MISMATCH=y'
        ",
                             sec_mismatch_count);
        #else
           err = 0; #endif return err;
    5. 解决fs编译报错
      1. jianrongzeng@zjr:linux$ grep -rnwI zjr ./fs/* -A 20
        ./fs/ext4/namei.c:3190:// zjr
        ./fs/ext4/namei.c-3191-#ifdef CONFIG_EXT4_FS_ENCRYPTION
        ./fs/ext4/namei.c-3192-        err = ext4_inherit_context(dir, inode);
        ./fs/ext4/namei.c-3193-        if (err)
        ./fs/ext4/namei.c-3194-            goto err_drop_inode;
        ./fs/ext4/namei.c-3195-#endif
        ./fs/ext4/namei.c-3196-        ctx = ext4_get_fname_crypto_ctx(inode,
        ./fs/ext4/namei.c-3197-                        inode->i_sb->s_blocksize);
        ./fs/ext4/namei.c-3198-        if (IS_ERR_OR_NULL(ctx)) {
        ./fs/ext4/namei.c-3199-            /* We just set the policy, so ctx should not be NULL */
        ./fs/ext4/namei.c-3200-            err = (ctx == NULL) ? -EIO : PTR_ERR(ctx);
        ./fs/ext4/namei.c-3201-            goto err_drop_inode;
        ./fs/ext4/namei.c-3202-        }
        ./fs/ext4/namei.c-3203-        istr.name = (const unsigned char *) symname;
        ./fs/ext4/namei.c-3204-        istr.len = len;
        ./fs/ext4/namei.c-3205-        ostr.name = sd->encrypted_path;
        ./fs/ext4/namei.c-3206-        err = ext4_fname_usr_to_disk(ctx, &istr, &ostr);
        ./fs/ext4/namei.c-3207-        ext4_put_fname_crypto_ctx(&ctx);
        ./fs/ext4/namei.c-3208-        if (err < 0)
        ./fs/ext4/namei.c-3209-            goto err_drop_inode;
        ./fs/ext4/namei.c-3210-        sd->len = cpu_to_le16(ostr.len);
        --
        ./fs/ext4/ext4.h:2047:// zjr
        ./fs/ext4/ext4.h-2048-#ifdef CONFIG_EXT4_FS_ENCRYPTION
        ./fs/ext4/ext4.h-2049-int ext4_is_child_context_consistent_with_parent(struct inode *parent,
        ./fs/ext4/ext4.h-2050-                         struct inode *child);
        ./fs/ext4/ext4.h-2051-int ext4_inherit_context(struct inode *parent, struct inode *child);
        ./fs/ext4/ext4.h-2052-void ext4_to_hex(char *dst, char *src, size_t src_size);
        ./fs/ext4/ext4.h-2053-int ext4_process_policy(const struct ext4_encryption_policy *policy,
        ./fs/ext4/ext4.h-2054-            struct inode *inode);
        ./fs/ext4/ext4.h-2055-int ext4_get_policy(struct inode *inode,
        ./fs/ext4/ext4.h-2056-            struct ext4_encryption_policy *policy);
        ./fs/ext4/ext4.h-2057-#else
        ./fs/ext4/ext4.h-2058-static inline int ext4_is_child_context_consistent_with_parent(struct inode *parent,
        ./fs/ext4/ext4.h-2059-                         struct inode *child) { return 0; }
        ./fs/ext4/ext4.h-2060-//static inline int ext4_inherit_context(struct inode *parent, struct inode *child);
        ./fs/ext4/ext4.h-2061-static inline void ext4_to_hex(char *dst, char *src, size_t src_size) {}
        ./fs/ext4/ext4.h-2062-static inline int ext4_process_policy(const struct ext4_encryption_policy *policy,
        ./fs/ext4/ext4.h-2063-            struct inode *inode) { return 0; }
        ./fs/ext4/ext4.h-2064-static inline int ext4_get_policy(struct inode *inode,
        ./fs/ext4/ext4.h-2065-            struct ext4_encryption_policy *policy) { return 0; }
        ./fs/ext4/ext4.h-2066-#endif
        ./fs/ext4/ext4.h-2067-
        --
        ./fs/ext4/ext4.h:2069:// zjr
        ./fs/ext4/ext4.h-2070-#ifdef CONFIG_EXT4_FS_ENCRYPTION
        ./fs/ext4/ext4.h-2071-bool ext4_valid_contents_enc_mode(uint32_t mode);
        ./fs/ext4/ext4.h-2072-uint32_t ext4_validate_encryption_key_size(uint32_t mode, uint32_t size);
        ./fs/ext4/ext4.h-2073-extern struct workqueue_struct *ext4_read_workqueue;
        ./fs/ext4/ext4.h-2074-struct ext4_crypto_ctx *ext4_get_crypto_ctx(struct inode *inode);
        ./fs/ext4/ext4.h-2075-void ext4_release_crypto_ctx(struct ext4_crypto_ctx *ctx);
        ./fs/ext4/ext4.h-2076-void ext4_restore_control_page(struct page *data_page);
        ./fs/ext4/ext4.h-2077-struct page *ext4_encrypt(struct inode *inode,
        ./fs/ext4/ext4.h-2078-              struct page *plaintext_page);
        ./fs/ext4/ext4.h-2079-int ext4_decrypt(struct ext4_crypto_ctx *ctx, struct page *page);
        ./fs/ext4/ext4.h-2080-int ext4_decrypt_one(struct inode *inode, struct page *page);
        ./fs/ext4/ext4.h-2081-int ext4_encrypted_zeroout(struct inode *inode, struct ext4_extent *ex);
        ./fs/ext4/ext4.h-2082-#else
        ./fs/ext4/ext4.h-2083-static inline bool ext4_valid_contents_enc_mode(uint32_t mode) { return true; }
        ./fs/ext4/ext4.h-2084-static inline uint32_t ext4_validate_encryption_key_size(uint32_t mode, uint32_t size) { return 0; }
        ./fs/ext4/ext4.h-2085-static struct workqueue_struct *ext4_read_workqueue;
        ./fs/ext4/ext4.h-2086-static inline struct ext4_crypto_ctx *ext4_get_crypto_ctx(struct inode *inode) { return NULL; }
        ./fs/ext4/ext4.h-2087-static inline void ext4_release_crypto_ctx(struct ext4_crypto_ctx *ctx) {}
        ./fs/ext4/ext4.h-2088-static inline void ext4_restore_control_page(struct page *data_page) {}
        ./fs/ext4/ext4.h-2089-static inline struct page *ext4_encrypt(struct inode *inode,
        --
        ./fs/ext4/ext4.h:2113:// zjr
        ./fs/ext4/ext4.h-2114-#ifdef CONFIG_EXT4_FS_ENCRYPTION
        ./fs/ext4/ext4.h-2115-bool ext4_valid_filenames_enc_mode(uint32_t mode);
        ./fs/ext4/ext4.h-2116-u32 ext4_fname_crypto_round_up(u32 size, u32 blksize);
        ./fs/ext4/ext4.h-2117-int ext4_fname_crypto_alloc_buffer(struct ext4_fname_crypto_ctx *ctx,
        ./fs/ext4/ext4.h-2118-                   u32 ilen, struct ext4_str *crypto_str);
        ./fs/ext4/ext4.h-2119-int _ext4_fname_disk_to_usr(struct ext4_fname_crypto_ctx *ctx,
        ./fs/ext4/ext4.h-2120-                struct dx_hash_info *hinfo,
        ./fs/ext4/ext4.h-2121-                const struct ext4_str *iname,
        ./fs/ext4/ext4.h-2122-                struct ext4_str *oname);
        ./fs/ext4/ext4.h-2123-int ext4_fname_disk_to_usr(struct ext4_fname_crypto_ctx *ctx,
        ./fs/ext4/ext4.h-2124-               struct dx_hash_info *hinfo,
        ./fs/ext4/ext4.h-2125-               const struct ext4_dir_entry_2 *de,
        ./fs/ext4/ext4.h-2126-               struct ext4_str *oname);
        ./fs/ext4/ext4.h-2127-int ext4_fname_usr_to_disk(struct ext4_fname_crypto_ctx *ctx,
        ./fs/ext4/ext4.h-2128-               const struct qstr *iname,
        ./fs/ext4/ext4.h-2129-               struct ext4_str *oname);
        ./fs/ext4/ext4.h-2130-int ext4_fname_usr_to_hash(struct ext4_fname_crypto_ctx *ctx,
        ./fs/ext4/ext4.h-2131-               const struct qstr *iname,
        ./fs/ext4/ext4.h-2132-               struct dx_hash_info *hinfo);
        ./fs/ext4/ext4.h-2133-int ext4_fname_crypto_namelen_on_disk(struct ext4_fname_crypto_ctx *ctx,
        --
        ./fs/ext4/ext4.h:2184:// zjr
        ./fs/ext4/ext4.h-2185-#ifdef CONFIG_EXT4_FS_ENCRYPTION
        ./fs/ext4/ext4.h-2186-int ext4_generate_encryption_key(struct inode *inode);
        ./fs/ext4/ext4.h-2187-#else 
        ./fs/ext4/ext4.h-2188-static inline 
        ./fs/ext4/ext4.h-2189-int ext4_generate_encryption_key(struct inode *inode) { return 0; }
        ./fs/ext4/ext4.h-2190-#endif
  • 相关阅读:
    Largest Rectangle in Histogram, 求矩形图中最大的长方形面积
    MergeSortedArray,合并两个有序的数组
    Remove Duplicates from Sorted List ,除去链表中相邻的重复元素
    Word Search, 在矩阵中寻找字符串,回溯算法
    SubSets,SubSets2, 求数组所有子集
    Longest Substring Without Repeating Characters,求没有重复字符的最长字串
    Minimum Window Substring, 包含子串的最小窗口,双指针
    Sort Colors,颜色排序
    Search a 2D Matrix,在有序矩阵查找,二分查找的变形; 行有序,列有序查找。
    EditDistance,求两个字符串最小编辑距离,动态规划
  • 原文地址:https://www.cnblogs.com/zengjianrong/p/13063363.html
Copyright © 2020-2023  润新知