[Mips] Create and initialize _gp symbol.
llvm-svn: 199239
This commit is contained in:
		
							parent
							
								
									3b1a761374
								
							
						
					
					
						commit
						db2e1f35d8
					
				| 
						 | 
				
			
			@ -157,6 +157,7 @@ bool MipsTargetHandler::createImplicitFiles(
 | 
			
		|||
 | 
			
		||||
  if (_context.isDynamic()) {
 | 
			
		||||
    file->addAbsoluteAtom("_GLOBAL_OFFSET_TABLE_");
 | 
			
		||||
    file->addAbsoluteAtom("_gp");
 | 
			
		||||
    file->addAbsoluteAtom("_gp_disp");
 | 
			
		||||
  }
 | 
			
		||||
  result.push_back(std::move(file));
 | 
			
		||||
| 
						 | 
				
			
			@ -173,6 +174,12 @@ void MipsTargetHandler::finalizeSymbolValues() {
 | 
			
		|||
    assert(gotAtomIter != _targetLayout.absoluteAtoms().end());
 | 
			
		||||
    (*gotAtomIter)->_virtualAddr = gotSection ? gotSection->virtualAddr() : 0;
 | 
			
		||||
 | 
			
		||||
    auto gpAtomIter = _targetLayout.findAbsoluteAtom("_gp");
 | 
			
		||||
    assert(gpAtomIter != _targetLayout.absoluteAtoms().end());
 | 
			
		||||
    (*gpAtomIter)->_virtualAddr =
 | 
			
		||||
        gotSection ? gotSection->virtualAddr() + _targetLayout.getGPOffset()
 | 
			
		||||
                   : 0;
 | 
			
		||||
 | 
			
		||||
    auto gpDispAtomIter = _targetLayout.findAbsoluteAtom("_gp_disp");
 | 
			
		||||
    assert(gpDispAtomIter != _targetLayout.absoluteAtoms().end());
 | 
			
		||||
    _gpDispSymAtom = (*gpDispAtomIter);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -21,7 +21,7 @@ CHECK:  Machine: EM_MIPS (0x8)
 | 
			
		|||
CHECK:  Version: 1
 | 
			
		||||
CHECK:  Entry: 0x170
 | 
			
		||||
CHECK:  ProgramHeaderOffset: 0x34
 | 
			
		||||
CHECK:  SectionHeaderOffset: 0x21C8
 | 
			
		||||
CHECK:  SectionHeaderOffset: 0x21D8
 | 
			
		||||
CHECK:  Flags [ (0x0)
 | 
			
		||||
CHECK:  ]
 | 
			
		||||
CHECK:  HeaderSize: 52
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,6 +9,7 @@
 | 
			
		|||
# SHARED:   6 .got          00000008 0000000000001000 DATA 
 | 
			
		||||
# SHARED: SYMBOL TABLE:
 | 
			
		||||
# SHARED: 00001000 g       *ABS*  00000000 _GLOBAL_OFFSET_TABLE_
 | 
			
		||||
# SHARED: 00008ff0 g       *ABS*  00000000 _gp
 | 
			
		||||
# SHARED: 00008ff0 g       *ABS*  00000000 _gp_disp
 | 
			
		||||
 | 
			
		||||
# RUN: lld -flavor gnu -target mipsel -e main --noinhibit-exec -o %t2 %t1
 | 
			
		||||
| 
						 | 
				
			
			@ -19,6 +20,7 @@
 | 
			
		|||
# EXE:   7 .got          00000008 0000000000401000 DATA
 | 
			
		||||
# EXE: SYMBOL TABLE:
 | 
			
		||||
# EXE: 00401000 g       *ABS*  00000000 _GLOBAL_OFFSET_TABLE_
 | 
			
		||||
# EXE: 00408ff0 g       *ABS*  00000000 _gp
 | 
			
		||||
# EXE: 00408ff0 g       *ABS*  00000000 _gp_disp
 | 
			
		||||
 | 
			
		||||
    .global main
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue