[PATCH 11/11] Add test for objdump new feature which display global variable information based on DWARF info section

Jan Beulich jbeulich@suse.com
Fri Jun 13 12:06:47 GMT 2025


On 22.05.2025 13:03, Guillaume VACHERIAS wrote:
> --- /dev/null
> +++ b/binutils/testsuite/binutils-all/dw5-map-complex.S
> @@ -0,0 +1,809 @@
> +/* Copyright (C) 2017-2023 Free Software Foundation, Inc.
> +
> +   This program is free software; you can redistribute it and/or modify
> +   it under the terms of the GNU General Public License as published by
> +   the Free Software Foundation; either version 3 of the License, or
> +   (at your option) any later version.
> +
> +   This program is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +   GNU General Public License for more details.
> +
> +   You should have received a copy of the GNU General Public License
> +   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
> +
> +/* 
> +// Original dw5-map-complex.c file
> +
> +#include <stdio.h>
> +
> +// Global integer variable
> +int globalInt = 42;
> +
> +// Global character variable
> +char globalChar = 'A';
> +
> +// Global enumeration
> +enum Color { RED, GREEN, BLUE };
> +enum Color globalColor = GREEN;
> +
> +// Global array
> +int globalArray[5] = {1, 2, 3, 4, 5};
> +
> +// Global pointer
> +int* globalPointer = &globalInt;
> +
> +// Global constant
> +const double globalConstant = 3.14159;
> +
> +// Global union
> +union Data {
> +    int intVal;
> +    float floatVal;
> +    char charVal;
> +};
> +union Data globalData = { .intVal = 100 };
> +
> +// Typedef for structure
> +struct Person {
> +    char name[50];
> +    int age;
> +};
> +
> +// Global structure
> +struct Person globalPerson = {"Alice", 30};
> +
> +// Array of structures
> +struct Person globalPeople[3] = {
> +    {"Bob", 25},
> +    {"Charlie", 35},
> +    {"Diana", 28}
> +};
> +
> +// Recursive structure
> +struct Node {
> +    int value;
> +    struct Node* next;
> +};
> +struct Node globalNode = {10, NULL};
> +
> +// Array of enumeration
> +enum Color globalColors[3] = {RED, GREEN, BLUE};
> +
> +// Array of unions
> +union Data globalDataArray[2] = {
> +    {.intVal = 200},
> +    {.charVal = 'Z'}
> +};
> +
> +// Array of pointers
> +int* globalPointerArray[3] = {&globalArray[0], &globalArray[1], &globalArray[2]}; */
> +
> +	.file	"dw5-map-complex.c"
> +	.text
> +.Ltext0:
> +	.cfi_sections	.debug_frame
> +	.file 1 "dw5-map-complex.c"
> +	.global	globalInt
> +	.data
> +	.align	2
> +	.type	globalInt, %object
> +	.size	globalInt, 4
> +globalInt:
> +	.word	42
> +	.global	globalChar
> +	.type	globalChar, %object
> +	.size	globalChar, 1
> +globalChar:
> +	.byte	65
> +	.global	globalColor
> +	.type	globalColor, %object
> +	.size	globalColor, 1
> +globalColor:
> +	.byte	1
> +	.global	globalArray
> +	.align	2
> +	.type	globalArray, %object
> +	.size	globalArray, 20
> +globalArray:
> +	.word	1
> +	.word	2
> +	.word	3
> +	.word	4
> +	.word	5
> +	.global	globalPointer
> +	.align	2
> +	.type	globalPointer, %object
> +	.size	globalPointer, 4
> +globalPointer:
> +	.word	globalInt
> +	.global	globalConstant
> +	.section	.rodata
> +	.align	3
> +	.type	globalConstant, %object
> +	.size	globalConstant, 8
> +globalConstant:
> +	.word	-266631570
> +	.word	1074340345
> +	.global	globalData
> +	.data
> +	.align	2
> +	.type	globalData, %object
> +	.size	globalData, 4
> +globalData:
> +	.word	100
> +	.global	globalPerson
> +	.align	2
> +	.type	globalPerson, %object
> +	.size	globalPerson, 56
> +globalPerson:
> +	.ascii	"Alice\000"
> +	.space	44
> +	.space	2
> +	.word	30
> +	.global	globalPeople
> +	.align	2
> +	.type	globalPeople, %object
> +	.size	globalPeople, 168
> +globalPeople:
> +	.ascii	"Bob\000"
> +	.space	46
> +	.space	2
> +	.word	25
> +	.ascii	"Charlie\000"
> +	.space	42
> +	.space	2
> +	.word	35
> +	.ascii	"Diana\000"
> +	.space	44
> +	.space	2
> +	.word	28
> +	.global	globalNode
> +	.align	2
> +	.type	globalNode, %object
> +	.size	globalNode, 8
> +globalNode:
> +	.word	10
> +	.word	0
> +	.global	globalColors
> +	.align	2
> +	.type	globalColors, %object
> +	.size	globalColors, 3
> +globalColors:
> +	.byte	0
> +	.byte	1
> +	.byte	2
> +	.global	globalDataArray
> +	.align	2
> +	.type	globalDataArray, %object
> +	.size	globalDataArray, 8
> +globalDataArray:
> +	.word	200
> +	.byte	90
> +	.space	3
> +	.global	globalPointerArray
> +	.align	2
> +	.type	globalPointerArray, %object
> +	.size	globalPointerArray, 12
> +globalPointerArray:
> +	.word	globalArray
> +	.word	globalArray+4
> +	.word	globalArray+8
> +	.text
> +.Letext0:
> +	.section	.debug_info,"",%progbits
> +.Ldebug_info0:
> +	.4byte	0x266
> +	.2byte	0x5
> +	.byte	0x1
> +	.byte	0x4
> +	.4byte	.Ldebug_abbrev0
> +	.uleb128 0xa
> +	.4byte	.LASF36
> +	.byte	0x1d
> +	.4byte	.LASF37
> +	.4byte	.LASF38
> +	.4byte	.Ldebug_line0
> +	.uleb128 0x1
> +	.byte	0x1
> +	.byte	0x6
> +	.4byte	.LASF0
> +	.uleb128 0x1
> +	.byte	0x1
> +	.byte	0x8
> +	.4byte	.LASF1
> +	.uleb128 0x1
> +	.byte	0x2
> +	.byte	0x5
> +	.4byte	.LASF2
> +	.uleb128 0x1
> +	.byte	0x2
> +	.byte	0x7
> +	.4byte	.LASF3
> +	.uleb128 0x1
> +	.byte	0x4
> +	.byte	0x5
> +	.4byte	.LASF4
> +	.uleb128 0x1
> +	.byte	0x4
> +	.byte	0x7
> +	.4byte	.LASF5
> +	.uleb128 0x1
> +	.byte	0x8
> +	.byte	0x5
> +	.4byte	.LASF6
> +	.uleb128 0x1
> +	.byte	0x8
> +	.byte	0x7
> +	.4byte	.LASF7
> +	.uleb128 0xb
> +	.byte	0x4
> +	.byte	0x5
> +	.ascii	"int\000"
> +	.uleb128 0x1
> +	.byte	0x4
> +	.byte	0x7
> +	.4byte	.LASF8
> +	.uleb128 0x1
> +	.byte	0x8
> +	.byte	0x4
> +	.4byte	.LASF9
> +	.uleb128 0x1
> +	.byte	0x1
> +	.byte	0x8
> +	.4byte	.LASF10
> +	.uleb128 0x2
> +	.4byte	.LASF11
> +	.byte	0x4
> +	.byte	0x5
> +	.4byte	0x56
> +	.uleb128 0x5
> +	.byte	0x3
> +	.4byte	globalInt
> +	.uleb128 0x2
> +	.4byte	.LASF12
> +	.byte	0x7
> +	.byte	0x6
> +	.4byte	0x6b
> +	.uleb128 0x5
> +	.byte	0x3
> +	.4byte	globalChar
> +	.uleb128 0xc
> +	.4byte	.LASF39
> +	.byte	0x7
> +	.byte	0x1
> +	.4byte	0x25
> +	.byte	0x1
> +	.byte	0xa
> +	.byte	0x6
> +	.4byte	0xb9
> +	.uleb128 0xd
> +	.ascii	"RED\000"
> +	.byte	0
> +	.uleb128 0x7
> +	.4byte	.LASF13
> +	.byte	0x1
> +	.uleb128 0x7
> +	.4byte	.LASF14
> +	.byte	0x2
> +	.byte	0
> +	.uleb128 0x2
> +	.4byte	.LASF15
> +	.byte	0xb
> +	.byte	0xc
> +	.4byte	0x94
> +	.uleb128 0x5
> +	.byte	0x3
> +	.4byte	globalColor
> +	.uleb128 0x3
> +	.4byte	0x56
> +	.4byte	0xda
> +	.uleb128 0x4
> +	.4byte	0x5d
> +	.byte	0x4
> +	.byte	0
> +	.uleb128 0x2
> +	.4byte	.LASF16
> +	.byte	0xe
> +	.byte	0x5
> +	.4byte	0xca
> +	.uleb128 0x5
> +	.byte	0x3
> +	.4byte	globalArray
> +	.uleb128 0x2
> +	.4byte	.LASF17
> +	.byte	0x11
> +	.byte	0x6
> +	.4byte	0xfc
> +	.uleb128 0x5
> +	.byte	0x3
> +	.4byte	globalPointer
> +	.uleb128 0x8
> +	.4byte	0x56
> +	.uleb128 0x2
> +	.4byte	.LASF18
> +	.byte	0x14
> +	.byte	0xe
> +	.4byte	0x119
> +	.uleb128 0x5
> +	.byte	0x3
> +	.4byte	globalConstant
> +	.uleb128 0x1
> +	.byte	0x8
> +	.byte	0x4
> +	.4byte	.LASF19
> +	.uleb128 0xe
> +	.4byte	0x112
> +	.uleb128 0xf
> +	.4byte	.LASF40
> +	.byte	0x4
> +	.byte	0x1
> +	.byte	0x17
> +	.byte	0x7
> +	.4byte	0x14d
> +	.uleb128 0x5
> +	.4byte	.LASF20
> +	.byte	0x18
> +	.byte	0x9
> +	.4byte	0x56
> +	.uleb128 0x5
> +	.4byte	.LASF21
> +	.byte	0x19
> +	.byte	0xb
> +	.4byte	0x14d
> +	.uleb128 0x5
> +	.4byte	.LASF22
> +	.byte	0x1a
> +	.byte	0xa
> +	.4byte	0x6b
> +	.byte	0
> +	.uleb128 0x1
> +	.byte	0x4
> +	.byte	0x4
> +	.4byte	.LASF23
> +	.uleb128 0x2
> +	.4byte	.LASF24
> +	.byte	0x1c
> +	.byte	0xc
> +	.4byte	0x11e
> +	.uleb128 0x5
> +	.byte	0x3
> +	.4byte	globalData
> +	.uleb128 0x9
> +	.4byte	.LASF28
> +	.byte	0x38
> +	.byte	0x1f
> +	.4byte	0x18a
> +	.uleb128 0x6
> +	.4byte	.LASF25
> +	.byte	0x20
> +	.byte	0xa
> +	.4byte	0x18a
> +	.byte	0
> +	.uleb128 0x10
> +	.ascii	"age\000"
> +	.byte	0x1
> +	.byte	0x21
> +	.byte	0x9
> +	.4byte	0x56
> +	.byte	0x34
> +	.byte	0
> +	.uleb128 0x3
> +	.4byte	0x6b
> +	.4byte	0x19a
> +	.uleb128 0x4
> +	.4byte	0x5d
> +	.byte	0x31
> +	.byte	0
> +	.uleb128 0x2
> +	.4byte	.LASF26
> +	.byte	0x25
> +	.byte	0xf
> +	.4byte	0x165
> +	.uleb128 0x5
> +	.byte	0x3
> +	.4byte	globalPerson
> +	.uleb128 0x3
> +	.4byte	0x165
> +	.4byte	0x1bb
> +	.uleb128 0x4
> +	.4byte	0x5d
> +	.byte	0x2
> +	.byte	0
> +	.uleb128 0x2
> +	.4byte	.LASF27
> +	.byte	0x28
> +	.byte	0xf
> +	.4byte	0x1ab
> +	.uleb128 0x5
> +	.byte	0x3
> +	.4byte	globalPeople
> +	.uleb128 0x9
> +	.4byte	.LASF29
> +	.byte	0x8
> +	.byte	0x2f
> +	.4byte	0x1f0
> +	.uleb128 0x6
> +	.4byte	.LASF30
> +	.byte	0x30
> +	.byte	0x9
> +	.4byte	0x56
> +	.byte	0
> +	.uleb128 0x6
> +	.4byte	.LASF31
> +	.byte	0x31
> +	.byte	0x12
> +	.4byte	0x1f0
> +	.byte	0x4
> +	.byte	0
> +	.uleb128 0x8
> +	.4byte	0x1cc
> +	.uleb128 0x2
> +	.4byte	.LASF32
> +	.byte	0x33
> +	.byte	0xd
> +	.4byte	0x1cc
> +	.uleb128 0x5
> +	.byte	0x3
> +	.4byte	globalNode
> +	.uleb128 0x3
> +	.4byte	0x94
> +	.4byte	0x216
> +	.uleb128 0x4
> +	.4byte	0x5d
> +	.byte	0x2
> +	.byte	0
> +	.uleb128 0x2
> +	.4byte	.LASF33
> +	.byte	0x36
> +	.byte	0xc
> +	.4byte	0x206
> +	.uleb128 0x5
> +	.byte	0x3
> +	.4byte	globalColors
> +	.uleb128 0x3
> +	.4byte	0x11e
> +	.4byte	0x237
> +	.uleb128 0x4
> +	.4byte	0x5d
> +	.byte	0x1
> +	.byte	0
> +	.uleb128 0x2
> +	.4byte	.LASF34
> +	.byte	0x39
> +	.byte	0xc
> +	.4byte	0x227
> +	.uleb128 0x5
> +	.byte	0x3
> +	.4byte	globalDataArray
> +	.uleb128 0x3
> +	.4byte	0xfc
> +	.4byte	0x258
> +	.uleb128 0x4
> +	.4byte	0x5d
> +	.byte	0x2
> +	.byte	0
> +	.uleb128 0x2
> +	.4byte	.LASF35
> +	.byte	0x3f
> +	.byte	0x6
> +	.4byte	0x248
> +	.uleb128 0x5
> +	.byte	0x3
> +	.4byte	globalPointerArray
> +	.byte	0
> +	.section	.debug_abbrev,"",%progbits
> +.Ldebug_abbrev0:
> +	.uleb128 0x1
> +	.uleb128 0x24
> +	.byte	0
> +	.uleb128 0xb
> +	.uleb128 0xb
> +	.uleb128 0x3e
> +	.uleb128 0xb
> +	.uleb128 0x3
> +	.uleb128 0xe
> +	.byte	0
> +	.byte	0
> +	.uleb128 0x2
> +	.uleb128 0x34
> +	.byte	0
> +	.uleb128 0x3
> +	.uleb128 0xe
> +	.uleb128 0x3a
> +	.uleb128 0x21
> +	.sleb128 1
> +	.uleb128 0x3b
> +	.uleb128 0xb
> +	.uleb128 0x39
> +	.uleb128 0xb
> +	.uleb128 0x49
> +	.uleb128 0x13
> +	.uleb128 0x3f
> +	.uleb128 0x19
> +	.uleb128 0x2
> +	.uleb128 0x18
> +	.byte	0
> +	.byte	0
> +	.uleb128 0x3
> +	.uleb128 0x1
> +	.byte	0x1
> +	.uleb128 0x49
> +	.uleb128 0x13
> +	.uleb128 0x1
> +	.uleb128 0x13
> +	.byte	0
> +	.byte	0
> +	.uleb128 0x4
> +	.uleb128 0x21
> +	.byte	0
> +	.uleb128 0x49
> +	.uleb128 0x13
> +	.uleb128 0x2f
> +	.uleb128 0xb
> +	.byte	0
> +	.byte	0
> +	.uleb128 0x5
> +	.uleb128 0xd
> +	.byte	0
> +	.uleb128 0x3
> +	.uleb128 0xe
> +	.uleb128 0x3a
> +	.uleb128 0x21
> +	.sleb128 1
> +	.uleb128 0x3b
> +	.uleb128 0xb
> +	.uleb128 0x39
> +	.uleb128 0xb
> +	.uleb128 0x49
> +	.uleb128 0x13
> +	.byte	0
> +	.byte	0
> +	.uleb128 0x6
> +	.uleb128 0xd
> +	.byte	0
> +	.uleb128 0x3
> +	.uleb128 0xe
> +	.uleb128 0x3a
> +	.uleb128 0x21
> +	.sleb128 1
> +	.uleb128 0x3b
> +	.uleb128 0xb
> +	.uleb128 0x39
> +	.uleb128 0xb
> +	.uleb128 0x49
> +	.uleb128 0x13
> +	.uleb128 0x38
> +	.uleb128 0xb
> +	.byte	0
> +	.byte	0
> +	.uleb128 0x7
> +	.uleb128 0x28
> +	.byte	0
> +	.uleb128 0x3
> +	.uleb128 0xe
> +	.uleb128 0x1c
> +	.uleb128 0xb
> +	.byte	0
> +	.byte	0
> +	.uleb128 0x8
> +	.uleb128 0xf
> +	.byte	0
> +	.uleb128 0xb
> +	.uleb128 0x21
> +	.sleb128 4
> +	.uleb128 0x49
> +	.uleb128 0x13
> +	.byte	0
> +	.byte	0
> +	.uleb128 0x9
> +	.uleb128 0x13
> +	.byte	0x1
> +	.uleb128 0x3
> +	.uleb128 0xe
> +	.uleb128 0xb
> +	.uleb128 0xb
> +	.uleb128 0x3a
> +	.uleb128 0x21
> +	.sleb128 1
> +	.uleb128 0x3b
> +	.uleb128 0xb
> +	.uleb128 0x39
> +	.uleb128 0x21
> +	.sleb128 8
> +	.uleb128 0x1
> +	.uleb128 0x13
> +	.byte	0
> +	.byte	0
> +	.uleb128 0xa
> +	.uleb128 0x11
> +	.byte	0x1
> +	.uleb128 0x25
> +	.uleb128 0xe
> +	.uleb128 0x13
> +	.uleb128 0xb
> +	.uleb128 0x3
> +	.uleb128 0xe
> +	.uleb128 0x1b
> +	.uleb128 0xe
> +	.uleb128 0x10
> +	.uleb128 0x17
> +	.byte	0
> +	.byte	0
> +	.uleb128 0xb
> +	.uleb128 0x24
> +	.byte	0
> +	.uleb128 0xb
> +	.uleb128 0xb
> +	.uleb128 0x3e
> +	.uleb128 0xb
> +	.uleb128 0x3
> +	.uleb128 0x8
> +	.byte	0
> +	.byte	0
> +	.uleb128 0xc
> +	.uleb128 0x4
> +	.byte	0x1
> +	.uleb128 0x3
> +	.uleb128 0xe
> +	.uleb128 0x3e
> +	.uleb128 0xb
> +	.uleb128 0xb
> +	.uleb128 0xb
> +	.uleb128 0x49
> +	.uleb128 0x13
> +	.uleb128 0x3a
> +	.uleb128 0xb
> +	.uleb128 0x3b
> +	.uleb128 0xb
> +	.uleb128 0x39
> +	.uleb128 0xb
> +	.uleb128 0x1
> +	.uleb128 0x13
> +	.byte	0
> +	.byte	0
> +	.uleb128 0xd
> +	.uleb128 0x28
> +	.byte	0
> +	.uleb128 0x3
> +	.uleb128 0x8
> +	.uleb128 0x1c
> +	.uleb128 0xb
> +	.byte	0
> +	.byte	0
> +	.uleb128 0xe
> +	.uleb128 0x26
> +	.byte	0
> +	.uleb128 0x49
> +	.uleb128 0x13
> +	.byte	0
> +	.byte	0
> +	.uleb128 0xf
> +	.uleb128 0x17
> +	.byte	0x1
> +	.uleb128 0x3
> +	.uleb128 0xe
> +	.uleb128 0xb
> +	.uleb128 0xb
> +	.uleb128 0x3a
> +	.uleb128 0xb
> +	.uleb128 0x3b
> +	.uleb128 0xb
> +	.uleb128 0x39
> +	.uleb128 0xb
> +	.uleb128 0x1
> +	.uleb128 0x13
> +	.byte	0
> +	.byte	0
> +	.uleb128 0x10
> +	.uleb128 0xd
> +	.byte	0
> +	.uleb128 0x3
> +	.uleb128 0x8
> +	.uleb128 0x3a
> +	.uleb128 0xb
> +	.uleb128 0x3b
> +	.uleb128 0xb
> +	.uleb128 0x39
> +	.uleb128 0xb
> +	.uleb128 0x49
> +	.uleb128 0x13
> +	.uleb128 0x38
> +	.uleb128 0xb
> +	.byte	0
> +	.byte	0
> +	.byte	0
> +	.section	.debug_aranges,"",%progbits
> +	.4byte	0x14
> +	.2byte	0x2
> +	.4byte	.Ldebug_info0
> +	.byte	0x4
> +	.byte	0
> +	.2byte	0
> +	.2byte	0
> +	.4byte	0
> +	.4byte	0
> +	.section	.debug_line,"",%progbits
> +.Ldebug_line0:
> +	.section	.debug_str,"MS",%progbits,1
> +.LASF21:
> +	.ascii	"floatVal\000"
> +.LASF12:
> +	.ascii	"globalChar\000"
> +.LASF29:
> +	.ascii	"Node\000"
> +.LASF31:
> +	.ascii	"next\000"
> +.LASF30:
> +	.ascii	"value\000"
> +.LASF33:
> +	.ascii	"globalColors\000"
> +.LASF17:
> +	.ascii	"globalPointer\000"
> +.LASF23:
> +	.ascii	"float\000"
> +.LASF32:
> +	.ascii	"globalNode\000"
> +.LASF1:
> +	.ascii	"unsigned char\000"
> +.LASF34:
> +	.ascii	"globalDataArray\000"
> +.LASF5:
> +	.ascii	"long unsigned int\000"
> +.LASF27:
> +	.ascii	"globalPeople\000"
> +.LASF3:
> +	.ascii	"short unsigned int\000"
> +.LASF16:
> +	.ascii	"globalArray\000"
> +.LASF19:
> +	.ascii	"double\000"
> +.LASF22:
> +	.ascii	"charVal\000"
> +.LASF40:
> +	.ascii	"Data\000"
> +.LASF2:
> +	.ascii	"short int\000"
> +.LASF13:
> +	.ascii	"GREEN\000"
> +.LASF15:
> +	.ascii	"globalColor\000"
> +.LASF37:
> +	.ascii	"dw5-map-complex.c\000"
> +.LASF11:
> +	.ascii	"globalInt\000"
> +.LASF8:
> +	.ascii	"unsigned int\000"
> +.LASF14:
> +	.ascii	"BLUE\000"
> +.LASF28:
> +	.ascii	"Person\000"
> +.LASF7:
> +	.ascii	"long long unsigned int\000"
> +.LASF20:
> +	.ascii	"intVal\000"
> +.LASF26:
> +	.ascii	"globalPerson\000"
> +.LASF24:
> +	.ascii	"globalData\000"
> +.LASF6:
> +	.ascii	"long long int\000"
> +.LASF39:
> +	.ascii	"Color\000"
> +.LASF25:
> +	.ascii	"name\000"
> +.LASF35:
> +	.ascii	"globalPointerArray\000"
> +.LASF38:
> +	.ascii	"/home/vacherig/gcc-workdir/upstream/binutils-gdb\000"
> +.LASF4:
> +	.ascii	"long int\000"
> +.LASF10:
> +	.ascii	"char\000"
> +.LASF9:
> +	.ascii	"long double\000"
> +.LASF18:
> +	.ascii	"globalConstant\000"
> +.LASF0:
> +	.ascii	"signed char\000"

This kind of test source is (imo) pretty much unmaintainable.

> --- /dev/null
> +++ b/binutils/testsuite/binutils-all/dw5-map.S
> @@ -0,0 +1,430 @@
> +/* Copyright (C) 2017-2023 Free Software Foundation, Inc.
> +
> +   This program is free software; you can redistribute it and/or modify
> +   it under the terms of the GNU General Public License as published by
> +   the Free Software Foundation; either version 3 of the License, or
> +   (at your option) any later version.
> +
> +   This program is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +   GNU General Public License for more details.
> +
> +   You should have received a copy of the GNU General Public License
> +   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
> +	.cpu cortex-m0
> +	.arch armv6s-m
> +	.fpu softvfp
> +	.eabi_attribute 20, 1
> +	.eabi_attribute 21, 1
> +	.eabi_attribute 23, 3
> +	.eabi_attribute 24, 1
> +	.eabi_attribute 25, 1
> +	.eabi_attribute 26, 1
> +	.eabi_attribute 30, 6
> +	.eabi_attribute 34, 0
> +	.eabi_attribute 18, 4

How's this going to work for targets other than arm-*-*?

> --- /dev/null
> +++ b/binutils/testsuite/binutils-all/dw5.Y
> @@ -0,0 +1,5 @@
> +.*dw5.o:     file format .*
> +
> +(0x)?1234 (0x)?1238 pvar \(int\)
> +(0x)?1234 (0x)?1238 yvar \(int\)
> +(0x)?1234 (0x)?1238 xvar \(int\)
> \ No newline at end of file

Please don't introduce files lacking a trailing newline.

> --- /dev/null
> +++ b/binutils/testsuite/binutils-all/objdump-complex.Y
> @@ -0,0 +1,86 @@
> +.*dw5-map-complex.o:     file format .*
> +
> +(0x)?118 (0x)?124 globalPointerArray \(int\)
> +	(0x)?118 globalPointerArray\[0\]
> +	(0x)?11c globalPointerArray\[1\]
> +	(0x)?120 globalPointerArray\[2\]

How can the 0x sensibly be optional anywhere here? I agree ...

> +(0x)?0 (0x)?8 globalConstant \(double\)

... it's fine to be omitted e.g. here, as single-digit numbers are unambiguous.

> --- a/binutils/testsuite/binutils-all/objdump.exp
> +++ b/binutils/testsuite/binutils-all/objdump.exp
> @@ -545,6 +545,74 @@ if { ![is_elf_format]
>      }
>  }
>  
> +# Test objdump -Y on file containing debug_info
> +
> +if { ![is_elf_format] } then {
> +    unsupported "objdump map-file test"
> +} elseif { ![binutils_assemble $srcdir/$subdir/dw5.S tmpdir/dw5.${obj}] } then {
> +    fail "objdump map file"
> +} else {
> +    if [is_remote host] {
> +	set map_testfile [remote_download host tmpdir/dw5.${obj}]
> +    } else {
> +	set map_testfile tmpdir/dw5.${obj}
> +    }
> +
> +    set got [remote_exec host "$OBJDUMP $OBJDUMPFLAGS -Y $map_testfile" "" "/dev/null" "objdump.out"]
> +
> +    if { [regexp_diff objdump.out $srcdir/$subdir/dw5.Y] } then {
> +	fail "objdump -Y dw5.o"
> +    } else {
> +	pass "objdump -Y dw5.o"
> +    }
> +}
> +
> +# Test objdump -Y on file containing debug_info
> +
> +if { ![is_elf_format] } then {
> +    unsupported "objdump map-file test"
> +} elseif { ![binutils_assemble $srcdir/$subdir/dw5-map.S tmpdir/dw5-map.${obj}] } then {
> +    fail "objdump map file"
> +} else {
> +    set result [binutils_assemble $srcdir/$subdir/dw5-map.S tmpdir/dw5-map.${obj}]
> +    if [is_remote host] {
> +	set map_testfile [remote_download host tmpdir/dw5-map.${obj}]
> +    } else {
> +	set map_testfile tmpdir/dw5-map.${obj}
> +    }
> +
> +    set got [remote_exec host "$OBJDUMP $OBJDUMPFLAGS -Y $map_testfile" "" "/dev/null" "objdump.out"]
> +
> +    if { [regexp_diff objdump.out $srcdir/$subdir/objdump.Y] } then {
> +	fail "objdump -Y dw5-map.o"
> +    } else {
> +	pass "objdump -Y dw5-map.o"
> +    }
> +}
> +
> +# Test objdump -Y on file containing debug_info
> +
> +if { ![is_elf_format] } then {
> +    unsupported "objdump map-file test"
> +} elseif { ![binutils_assemble $srcdir/$subdir/dw5-map-complex.S tmpdir/dw5-map-complex.${obj}] } then {
> +    fail "objdump map file"
> +} else {
> +    set result [binutils_assemble $srcdir/$subdir/dw5-map-complex.S tmpdir/dw5-map-complex.${obj}]
> +    if [is_remote host] {
> +	set map_testfile [remote_download host tmpdir/dw5-map-complex.${obj}]
> +    } else {
> +	set map_testfile tmpdir/dw5-map-complex.${obj}
> +    }
> +
> +    set got [remote_exec host "$OBJDUMP $OBJDUMPFLAGS -Y $map_testfile" "" "/dev/null" "objdump.out"]
> +
> +    if { [regexp_diff objdump.out $srcdir/$subdir/objdump-complex.Y] } then {
> +	fail "objdump -Y dw5-map-complex.o"
> +    } else {
> +	pass "objdump -Y dw5-map-complex.o"
> +    }
> +}

Is all of this open-coding really needed? IOW can't you simply use
run_dump_test for the three tests?

Jan


More information about the Binutils mailing list